FastPrepTilting Maze Ball
Problems/Tilting Maze Ball

Tilting Maze Ball

Hudson River Trading logoHudson River Trading● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Hudson River Trading new grad phone screen. The linked interview task is a maze ball. It moves one cell per second under an up, down, left, right or flat tilt, with timed direction events and a requested final position. The linked report also describes sharing the direction logic and discussing how to speed up the event intervals. We chose the flat starting state, that an event happens before movement, strictly increasing integer event times, the limits, a character grid, and a zero-based coordinate as the answer. Our version and the optimization discussion are about 85% the same as the reported question. The original framework code and examples were not available.

A ball sits on an open cell . in a rectangular maze whose walls are #. The ball initially has direction F and does not move.

For each integer second from 1 through endTime, first apply a direction event at that second if one exists, then attempt to move the ball one cell in the current direction. Directions are U, D, L, R, and F. A move that would leave the maze or enter a wall is ignored; the direction remains active.

Return the ball's final zero-based [row, column].

Function

finalMazePosition(maze: String[], startRow: int, startCol: int, eventTimes: int[], directions: String[], endTime: int) → int[]

Examples

Example 1

maze = ["....",".##.","...."]startRow = 0startCol = 0eventTimes = [1,4,6]directions = ["R","D","L"]endTime = 8return = [2,0]
maze
01230....1.##.2....

The ball follows the open outer corridor and ends in the bottom-left corner.

Example 2

maze = ["...","...","..."]startRow = 1startCol = 1eventTimes = [2,3]directions = ["U","R"]endTime = 4return = [0,2]
maze
0120...1...2...

The ball waits during second 1, then moves up once and right once before the boundary stops it.

Example 3

maze = ["###","#.#","###"]startRow = 1startCol = 1eventTimes = [1]directions = ["R"]endTime = 3return = [1,1]
maze
0120###1#.#2###

Walls block every attempted move.

Constraints

  • 1 <= maze.length, maze[0].length <= 200.
  • 0 <= endTime <= 100000.
  • 0 <= eventTimes.length = directions.length <= endTime.
  • Event times are strictly increasing and each lies from 1 through endTime.
  • The start cell is open, and every direction is U, D, L, R, or F.

More Hudson River Trading Phone Screen questions

  • Format a Signed Integer with CommasPHONE SCREEN · Seen Nov 2026
  • Order and Batch Open-Close LifecyclePHONE SCREEN · Seen Nov 2026
  • Tiered Expiring Item StorePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Market Data Signal WatcherPHONE SCREEN · Seen Jul 2026
  • Integer to String Without Built-insPHONE SCREEN · Seen May 2026
  • Contact Tracing Through Timed MeetingsPHONE SCREEN · Seen Nov 2024
  • Polydivisible Pandigital NumbersPHONE SCREEN · Seen Feb 2024
  • Defragment a Buffer of ObjectsPHONE SCREEN · Seen Nov 2023
  • Read N Bytes with read4096 Across CallsPHONE SCREEN · Seen Oct 2023
  • Call Auction Clearing Price and Order FillsPHONE SCREEN · Seen Nov 2022

Similar questions at other companies

  • Grid Infection with Recovery After D DaysOpenAI · PHONE SCREEN
  • Days Until Poisoned Plants StabilizeApple · PHONE SCREEN
  • Apply a 2048 Board MoveGlean · PHONE SCREEN
  • Dense Matrix MultiplicationAmazon · PHONE SCREEN
  • File-Backed Dense Game of LifeApplied Intuition · PHONE SCREEN
  • Spiral Order with ObstaclesTemu · PHONE SCREEN
  • Logistic Regression DiagnosticsLinkedIn · PHONE SCREEN
  • Spiral Matrix TraversalByteDance · PHONE SCREEN
  • S-Shaped Matrix TraversalFox Corporation · PHONE SCREEN
  • Longest Consecutive Same-Color LineGoogle · PHONE SCREEN
See Hudson River Trading hiring insights
Saved
class Solution {
    public int[] finalMazePosition(String[] maze, int startRow, int startCol, int[] eventTimes, String[] directions, int endTime) {
        // Write your code here.
    }
}
Checking account…