4 Ways to Solve a Google Interview Question in JavaScript

A companion to Google’s official mock-interview video for developers.

Bret Cameron
6 min readMar 11, 2019

When I was first learning about the performance of algorithms, I stumbled across this video of a mock-interview at Google.

The video not only provides a useful insight into the interview process at larger tech firms, but it was also very helpful in advancing my understanding of how to tackle algorithmic problems in the most efficient way possible.

This article is intended to be a companion to Google’s video, providing a commentary on each possible solution given in the video, plus my own version of each solution in JavaScript.

We’ll also discuss the time and space complexity of each algorithm. Though you don’t need to understand what that means to follow along, those who are interested in finding out more might find my article on Big O Notation useful. Let’s dive in.

The Problem

We are given an ordered array and a value. We’re then asked to create a function which returns true or false, depending on whether any two integers in the array may be added together to equal the value.

In other words, are there any two integers, x and y , in our array that — when added — are equal…

--

--

Bret Cameron
Bret Cameron

Written by Bret Cameron

Writer and developer based in London. On Medium, I mainly write about JavaScript, web development and Rust 💻

Responses (10)