← Hudson Interview Insights

Hudson·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Got a coding round for an ML Engineer role at Hudson that turned out to be way more simulation-heavy than I expected. The main problem was a geometry/logic puzzle dressed up as a movement problem, and then they hit you with a continuous-time follow-up that I was not ready for.

Questions Asked (2)

Q1

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?

Algorithms & Data Structures
Author's notes

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.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a simulation over time, tracking each person's position and the watcher's state (position and direction). At each time step, update the watcher's direction based on the schedule, then move each person right by one unit unless they are strictly on the watcher's facing side. Count how many reach or pass L after T steps.

Pro tip: Clarify edge cases upfront: people exactly at W are unaffected, and the watcher's direction changes at specified times—likely before movement in that step. Also, consider if multiple people can occupy the same position; typically they can, so no collision handling is needed.

1. Parse inputs and initialize state

Read N, L, T, initial positions, W, initial direction, and reversal times. Initialize each person's position and the watcher's current direction.

2. Simulate each time step

For t from 1 to T: update watcher's direction if t is a reversal time; then for each person, if they are not strictly on the watcher's facing side, move them right by 1.

3. Track positions and count arrivals

After each move, check if a person's position is >= L. If so, mark them as arrived (or remove them from further movement) and increment a counter.

4. Return the count

After T steps, output the number of people who have reached or passed L.

Key Points to Mention

  • The watcher's direction changes at specified times; clarify whether this happens before or after movement in that step.
  • People exactly at W are unaffected by the watcher's direction.
  • Only people strictly on the watcher's facing side are blocked; those on the opposite side or at W can move.
  • Multiple people can occupy the same position; no collision handling is required.
  • A person who reaches L may continue moving if not removed, but typically they are considered arrived and stop.
  • Time complexity is O(N*T), which may be optimized if T is large, but simulation is straightforward for small constraints.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

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?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I kind of fell apart.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the new problem: the watcher's direction changes only at discrete switch times, but movement is continuous, so the watcher's position evolves linearly between switches. Then, adapt the step-based solution by replacing discrete position updates with continuous-time integration, while keeping the same decision points for direction changes. Finally, discuss the algorithmic implications, such as event-driven simulation or closed-form position calculations, and any trade-offs in complexity or precision.

Pro tip: Emphasize that the core insight—the watcher only makes decisions at discrete times—remains unchanged, so you can reuse the same decision logic and simply interpolate positions between switch times. This shows you can separate the problem's invariant structure from its implementation details.

1. Restate the problem and assumptions

Confirm that the watcher moves continuously at a constant speed (or known velocity) and only changes direction at discrete switch times. Clarify whether switch times are predetermined or adaptive.

2. Identify what changes from the step-based solution

In the step-based version, positions update at each step; now, positions must be computed as continuous functions of time between switches. The decision logic at switch times remains the same.

3. Choose a representation for continuous movement

Use event-driven simulation: maintain the watcher's position and direction, and jump from one switch time to the next, updating position via linear interpolation. Alternatively, derive closed-form expressions for position at any time.

4. Adapt the algorithm and data structures

Replace discrete step loops with a priority queue of switch times or a sorted list of events. For each interval, compute the watcher's trajectory and check for interactions (e.g., with targets) using continuous collision detection.

5. Analyze trade-offs and edge cases

Discuss complexity: event-driven may be O(k log k) for k switches vs. O(n) for n steps. Address precision issues, simultaneous events, and whether the watcher's speed is constant or variable.

Key Points to Mention

  • Event-driven simulation vs. fixed time-step simulation
  • Linear interpolation of position between switch times
  • Continuous collision detection or intersection tests
  • Complexity analysis: number of switches vs. number of steps
  • Handling simultaneous or overlapping events
  • Preserving the discrete decision logic at switch times

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.