Hello,
I had my phone technical about 6 weeks ago. Thought I'd share some insights.
I was given 2 questions to finish in 45 minutes.
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
1.1) Follow-up: How would we productionize this if the tree was constantly growing/shrinking?
1.1A) Very interesting follow-up. I mentioned that if each level could change, maybe we should utilize a dictionary to keep track of levels and then another ordered dictionary/set to keep track of the elements that are in each level (since it could constantly grow/shrink). We will add time complexity to convert the set to a list and reverse it, but it guarantees that we can quickly add/remove based on levels. The interviewer wasn't really looking for a correct answer, more like what would I do in this scenario. I honestly don't know if this answer was even the best method, but I think he was just looking for me to think beyond being an LC monkey.
Design a data structure class that will rate limit k RPS (requests per second). Similar to this (https://leetcode.com/problems/logger-rate-limiter/), but with k as an arbitrary input for a SINGLE SERVICE ID.
2.1) Follow-up: How would we utilize this same logger for multiple services with different IDs. How do we handle k RPS for N services?
2.A) I talked a lot about utilizing a queue to keep track of the k RPS per ID, but to also utilize a dictionary for each particular ID. So the dictionary would have key be the ID and value be the queue. This way we can route the correct k RPS for each unique ID. They also asked about what happens with multi-threading? I mentioned that we should NOT lock up the entire class, rather we should lock up each ID in the dictionary so that each thread with the same ID must wait in order.
Overall, interviewer was satisfied. None of the questions were hard, it was more on the follow-ups as discussion. Very interesting interview.
Results: Passed and was scheduled an onsite 2 weeks later.