Google Onsite L5 (India)
Anonymous User
4353

Round 1:

Given a set of photos ids (inclusive of favourite Ids), and favourite ids () (No duplicates in photos and favourites)
Write a **iterator** that returns favourite photos ids then photos ids (in the given order),
without any duplicate.
Input:
Photos: [p10,p2,p3,p4,p5,p6,p7,p8,....]
Favourite: [p8,p4,p10]
Output: 
[p8,p4,p10,p2,p3,p5,p6,p7,....]
Second Part: If Favourite and photos is given in sorted order, how would you optimize, as I have used the hashset?

**Edited**: for second part favourite and photos were given in sorted order.

Round 2:

Given a stream of message with timestamp,return the valid message in the same order of input 
having conditions that any duplicate messages that are with in 10 sec should be 
discarded (message at t and t+10 both need to be discarded).
Input:
10 a
12 b 
13 a
15 c
15 b
22 a
30 b
35 a
35 c
....

Output:
15c
30b
35a
35c
...

Round 3 :

There is a three-digit combination lock (like a suitcase lock) .Find the number of distinct combinations that will open the lock.
Each digit rotates in a circular fashion, for example, 0, 1, 2, 3, ...,  (numOptions - 1), 0, 1, 2, ...

There are two lock combinations that can unlock this, one set by the user and the other is a bypass combination.

The tolerance of error is "tolerance", meaning as long as each digit is within "tolerance" of the set number, the lock will open. 
A tolerance of 0 requires an exact match for the combination.

For example, if numOptions is 10 and tolerance is 2, with the user and the bypass combinations of:
[0 1 2] -> 1 1 1 would open
[3 4 5]

then either [0 9 4] or [1 3 7] can open the lock, but [0 4 5] will not.

Write a function to output the number of distinct lock combinations (mathematical permutations, since order matters) that can open the lock.

int countNumberCombinations(
    int[] user, 
    int[] bypass, 
    int tolerance, 
    int numOptions) {
    // Implement the function here
}

Round 4:

          Internal<len=26>
           /            \
  Leaf<len=5>:ABCDE     Internal<len=21>
                         /               \
            Leaf<len=10>:FGHIJKLMNO     Leaf<len=11>:PQRSTUVWXYZ
			
Had given this kind of structure where lead node will have some text along with it. 
First I need to write the datastructure or class to represent this structure.
Then write a function to find the substring in the given internal with strdindex and of given length 
String findSubstring(Internal iternal,int strIndex, int length) -> substring of internal

Input: Internal<len=21>, 5, 10
Output:  KLMNOPQRST 

Input: Internal<len=21>, 11, 5
Output:  QRSTUV

Approach: I have used the inorder travesal along with generating the string at every leaf node.

Update: Added round 4.

Comments (25)