This round's interview question: given some training sentences, write two functions — a training function and a predictor function. The predictor function should take a word as input and output what the first word after that word could be.
Example:
["I", "am", "Sam"]
["Sam", "I", "am"]
["I", "like", "green", "eggs", "and", "ham"]
My approach: in the training function, use a dictionary to count how many times each word's next word appears; in the predictor function, just iterate through this dictionary.
First follow-up: the predictor function above was O(k) time, where k is the number of possible next words, and they wanted it optimized to O(1).
My approach: during training, precompute each word's possible next words ahead of time and store them in a dictionary.
Second follow-up: now they wanted predict to return a probability-weighted result. For example, for the word "I", the next word could be "am" or "like" — "am" showed up twice as a next word and "like" showed up once, so the new predict function should return "like" with 1/3 probability and "am" with 2/3 probability.
My approach: use Python's built-in random.choices.
Second round was BQ:
- Tell the interviewer about your background and why you think you're a good fit for Google.
- Describe a problem your team ran into — how did you spot it and how did you solve it?
- If your project didn't ship on schedule, how would you explain that and what would you do to improve?
- If you went on an outdoor team activity with your Google team meant to build team cohesion, and you let team members vote on which activity they'd like, but some people don't want to participate, what would you do?
Discussion
Loading comments…