The Maze
Updated
Problem statement
A ball is placed in a rectangular maze represented by a binary matrix. Empty cells contain 0 and walls contain 1. The ball can move up, down, left, or right, but it keeps rolling in the chosen direction until a wall stops it.
Given the ball's start and destination cells, return true if the ball can stop at the destination and false otherwise.
Function
hasPath(maze: int[][], start: int[], destination: int[]) → booleanExamples
Example 1
maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]]start = [0,4]destination = [4,4]return = trueA sequence of rolls can stop the ball at the destination.
Example 2
maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]]start = [0,4]destination = [3,2]return = falseThe ball can pass through the destination cell but cannot stop there.
Constraints
1 <= maze.length, maze[0].length <= 100maze[i][j]is either0or1.startanddestinationeach contain two coordinates.- The start and destination cells are empty.
- The maze is surrounded by walls outside its boundary.
More Bloomberg LP Onsite Interview questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Number of IslandsIntuit · ONSITE INTERVIEWIntuit interview questions
- Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Shortest Bridge Between Two IslandsCompass International Holdings · ONSITE INTERVIEWCompass International Holdings interview questions
- Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
- Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
- Number of Closed IslandsSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
- Foreground Region SizesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- The MazeGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Mouse and Cheese ReachabilityMeta · ONSITE INTERVIEWMeta interview questions
- Number of IslandsTripjack · ONSITE INTERVIEWTripjack interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)