Recently appeared for a phone screen for SDE-2 position (Seattle, USA).
15 minutes: background introduction and LP question:
Question was on Leadership Principle INSIST ON THE HIGHEST STANDARDS:
Tell me about a time when you had to make a decision between reducing code quality standards to meet the tight deadline for delivery.
40 minutes: Coding Question:
Implement how the following use case can be optimized.
A program running on a mobile device with limited memory and computing power. It requires to access a certain set of resources from the server, once per time.
A simplified workflow could be:
Request resource A from server -> processed
Request resource A from server -> processed
Request resource B from server -> processed
Request resource A from server -> processed
Request resource B from server -> processed
Request resource B from server -> processed
Request resource B from server -> processed
Request resource A from server -> processed
Request resource C from server -> processed
Request resource A from server -> processed
Request resource C from server -> processed
Request resource D from server -> processed
If a resource is recently used, it will be very like to be accessed again. However, requesting resources from the server is an expensive operation for the backend service.The condition of being recently used and expensive server operations hint toward using an LRU Cache:
Explained the reasoning and started to implement it after explanation was accepted.
Refer for the implementation: https://leetcode.com/problems/lru-cache/