Level: Senior-Level
Round: Full Journey · Type: Multiple Types · Difficulty: 6/10 · Duration: 180 min · Interviewer: Neutral
Topics: Behavioral, System Design, Weighted Random Value Generator
Location: Seattle, WA, US
Interview date: 2025-12-20
Got offer: False
Question: Two behavioral questions: a complex problem with a simple solution, and influencing a peer with differing opinions.
Question: A behavioral question about delivering a project with compromises, and a coding question: weighted random value generator.
Question: A behavioral question about delivering a project under a tight deadline. The system design question was to design a system for collecting and displaying temperature sensor data.
Design a generic weighted random generator that supports adding weighted values and randomly returns a value according to its weight ratio.
fun add(value: T, weight: Int)
Example:
If the current value-weight pairs are [1, 1], [2, 1], [5, 3], then the probabilities of 1 and 2 are each 20%, and the probability of 5 is 60%.
If [3, 5] is added on this basis, then the probabilities of 1 and 2 are each 10%, 5 is 30%, and 3 is 50%.
The focus of implementation is on the clarity, maintainability, and scalability of the code, rather than pursuing optimal performance.
Follow up:
fun addWithExpiry(value: T, weight: Int, expireAfterMs: Int)
Design a system to collect and display massive temperature sensor data distributed across a large geographic area (e.g., Washington State).
Input: 1 million to 10 million temperature sensors, relatively evenly distributed within the area Sensors are low-cost and simple, and do not support mesh networks Sensors send data to the backend via HTTP, and both sides have IP addresses Temperature changes are not rapid, but the system needs to be able to track temperature changes of any sensor at a granularity of 10 seconds
Output: Near real-time temperature distribution map for web interface display When there are about 1 million sensors, 1 sensor can correspond to 1 pixel (4K screen can completely display) Support querying within a time range (such as a day or a year) for
Current temperature Minimum temperature Maximum temperature The system needs to be able to run stably for several years