Panda Guru LogoPanda
Guru

Google L4 interview expereince

Preliminary Screening

Questions: Let's define a kind of message called "Broadcast & Shut Down." When a router receives this message, it broadcasts the same message to all other routers within its wireless range. Then, that router shuts down, and can no longer send or receive messages.

For example, Router A is at (0, 0); Router B is at (0, 8); Router C is at (0, 17); Router D is at (11, 0). If the wireless range is 10, when Router A sends a message, it could first reach B; the message from Router B would further reach Router C but Router D would never receive this message. Given a list of routers' locations (their names and the corresponding 2D coordinates), a source router, a destination router, and the wireless range, tell me whether a message from the source router can reach the destination router. Write a method / function with appropriate input and output arguments.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Round 1

Questions: We have a file with the following format each line: startIP, endIP, cityName.
Question: Write a function that takes as input an IP address and outputs its associated cityName.
Example:
File format:
startIP, endIP, cityName
1.0.1.1, 1.0.1.10, NYC
1.0.1.20, 1.0.1.30, SF
...
If the input is 1.0.1.9, the output should be NYC.
Write code for the function.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Round 2

Questions: We define an organic molecule by a list of atoms, and a list of bonds between any two of them. For example, the following formaldehyde molecule:

H | H-C=O

is represented as:
atoms: {1: 'C', 2: 'H', 3: 'H', 4: 'O'}
bonds: [[1, 2], [1, 3], [1, 4], [1, 4]]
The input does not have to be strictly in this format, as long as it delivers the information.

Given an input representing a molecule consisting only of Carbon, Oxygen and Hydrogen atoms, determine if it's valid.

A molecule is valid if every atom has the required number of bonds:
C atoms require exactly 4 bonds
O atoms require exactly 2 bonds
H atoms require exactly 1 bond

dict_cnt_atoms = {1:4, 2:1, 3:1, 4:2} # O(len(bonds)) + O(len(atoms))
atoms: {1: 'C', 2: 'H', 3: 'H', 4: 'O'}

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Round 3

Questions: Given a sequence S of N digits, find a subsequence of K digits such that the number formed by these K digits (in order) is the largest.

Get the largest number sequence
You have sequence of k digits
S = 4902, K = 2, answer = 92
S = 4902, K = 3, answer = 902
S = 142857, K = 1, answer = 8
S = 142857, K = 2, answer = 87
S = 142857, K = 4, answer = 4857

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Additional HC Round

Questions: Generate brute force password attack list from "bad" keylogger and keyword list. Imagine that you have a "bad" or "weak" keylogger which only has a counter (map) of each key and the number of times it was pressed in the password, unordered. For instance, it might be a camera pointed at the keyboard, and you can't quite tell the order of the keys. So something like this:

{'a': 4, 'c': 1, 'e': 1, '1': 1}

Your goal, as an elite hacker, is to generate a list of possible passwords for a brute force attack.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.


Final Verdict