Google Interview Questions | Glassdoor

Companies matching "Google"

Google Interviews /  HQ: Mountain View, CA

5,052 Interviews

3.4 Difficult

Google Ventures Interviews /  HQ: Mountain View

0 Interviews

Not Yet Rated

Google eLearn Services Interviews /  HQ: Noida

0 Interviews

Not Yet Rated

Google Interview Questions

Sort: RelevancePopular Date

Given an array of numbers, replace each number with the product of all the numbers in the array except the number itself *without* using division.

8 Answers

O(size of array) time & space: First, realize that saying the element should be the product of all other numbers is like saying it is the product of all the numbers to the left, times the product of all the numbers to the right. This is the main idea. Call the original array A, with n elements. Index it with C notation, i.e. from A[0] to A[n - 1]. Create a new array B, also with n elements (can be uninitialized). Then, do this: Accumulator = 1 For i = 0 to n - 2: Accumulator *= A[i] B[i + 1] = Accumulator Accumulator = 1 For i = n - 1 down to 1: Accumulator *= A[i] B[i - 1] *= Accumulator Replace A with B It traverses A twice and executes 2n multiplicates, hence O(n) time It creates an array B with the same size as A, hence O(n) temporary space

# A Python solution (requires Python 2.5 or higher): def mult(arr, num): return reduce(lambda x,y: x*y if y!=num else x, arr) arr = [mult(arr,i) for i in arr] # O(n^2) time, O(n) space

Create two more arrays. One array contains the products of the elements going upward. That is, B[0] = A[0], B[1] = A[0] * A[1], B[2] = B[1] * A[2], and so on. The other array contains the products of the elements going down. That is, C[n] = A[n], C[n-1] = A[n] * A[n-1], and so on. Now A[i] is simply B[i-1] * C[i+1].

What sort would you use if you required tight max time bounds and wanted highly regular performance.

6 Answers

Implement a binary tree and explain it's function

4 Answers

You notice that adwords revenue for a certain word has dropped in Italy for the last 30 days. How do you go about determining why that has happened?

4 Answers

How do you represent a real-world quantity in a digital system?

1 Answer

If you have 10 bags of marbles with 10 marbles each and one bag has marbles that weigh differently than the others, how would you figure it out from one weighing

5 Answers

What would you say are the minimal requirements needed to successfully manage a software development project?

3 Answers

What are the three attributes you believe a successful technical recruiter should have?

2 Answers

How many cows are in Canada

101 Answers

How many people using facebook in San Francisco at 2:30pm on a Friday?

50 Answers
110 of 3,903 Interview Questions