Hudson River Trading·Machine Learning Engineer·Technical Phone Screen
- You have a 1D line segment with a right boundary at position L. N people start at given positions and all want to move right, one unit per time step, for T total steps. A stationary watcher at position W faces either left or right and reverses direction at specified times. Each step, any person strictly on the watcher's facing side cannot move. People at exactly W are unaffected. How many people reach position L after T steps?
- Follow-up: how would you adapt the solution if movement is continuous rather than step-based, while the watcher still only changes direction at discrete switch times?
“My first instinct was to just simulate it step by step, which is probably the right call, but I spent too long second-guessing whether there was some closed-form trick.”