Google | Engineering Productivity | MTV | Feb 2020 [Reject]

Phone Interview:

Onsite Interview

Round 1
Given a very long array which could be stored on more than one machines. The array is alphabetically sorted and contain strings.

A = ["a", "aa", "abc",........,"dog",...."sell".......]  

You are given an API A.get(index) that returns A[index]
Write an API reverseGet which should take a word as an argument and return its index in A

Example: 
A.reverseGet("abc") = 2

Condition 1: There is no way you can find length(A)
Condition 2: If the word is at k index, time complexity should be better than O(k)

Round 2
Open ended question – Write a program to find if text file B is plagiarized from text file A and return some kind of similarity metrics.

Hints : There will be problems if you do it on sentence/word or character basis.

Round 3
Given a matrix that represents an image in pixels. The matrix only contains 0s and 1s. Find all island of 1s and convert all elements in those islands to 0.

Condition 1: An island must contain only 1s.
Condition 2: An island is considered using top, left, bottom and right as neighboring nodes.
Condition 3: An island should not have any of its elements touch either top, left, right or bottom edge of the matrix

Input:

[1, 0, 1, 1, 1]
[0, 1, 0, 0, 0]
[0, 1, 1, 0, 0]
[0, 0, 0, 1, 1]

Output:

[1, 0, 1, 1, 1]
[0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 1, 1]

Round 4:

https://leetcode.com/problems/evaluate-reverse-polish-notation/
Write a program to find result of a postfix notation.

Input: “4 3 5 + *”
Output: 32

Write all the cases where an exception can come.

Round 5:

Similar question: Compare Expression Trees
Given two trees containing ‘A’, ‘B’, ‘C’, ‘D’, ‘|’, ‘&’ where A, B, C, D can take values of 0 or 1. Find if both the trees will evaluate the same results.

Example 1:

	Tree 1:

			 ‘|’
		   /    \
		 ‘|’     ‘C’
		/  \
	 ‘A’   ‘B’

	Tree 2: 

         ‘|’
       /    \
    ‘A’     ‘|’
            /  \
          ‘B’   ‘C’

Output : True (Same)

No Behavioural questions.

Comments (7)