Rolling Ball Maze Reachability

Last updated: August 15, 2026

Quick Overview

The candidate is asked to solve a problem where a ball is rolled in a maze and must determine if it can reach a specific destination.

Goldman Sachs
Coding & Algorithms
Software Engineer
Goldman Sachs
August 15, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

4 solved


The candidate is asked to solve a problem where a ball is rolled in a maze and must determine if it can reach a specific destination.

This question is typically asked during the onsite coding round at Goldman Sachs to assess a candidate's problem-solving and algorithmic skills. The interviewer evaluates the candidate's ability to implement efficient algorithms and their understanding of maze traversal techniques, which are crucial for developing robust software solutions in a fast-paced financial environment.

What the Interviewer Expects
  • Explain the approach to solving the maze problem clearly.
  • Implement a depth-first search (DFS) or breadth-first search (BFS) algorithm effectively.
  • Discuss time and space complexity of the solution.
  • Handle edge cases and provide a comprehensive solution.
  • Demonstrate clear coding practices and logical flow.
Key Topics to Cover
Graph Traversal
Depth-First Search
Breadth-First Search
Algorithm Complexity
Edge Cases
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you optimize your solution for larger mazes?
  • Can you explain how you would handle obstacles in the maze?
  • What would you change if the maze had dynamic walls?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Approach

To determine if the ball can reach the destination in the maze, we can use graph traversal techniques such as Depth-First Search (DFS) or Breadth-First Search (BFS). The maze can be represented as a g...

Algorithm

We can implement the algorithm using BFS for this problem. Here’s a step-by-step outline:

  1. Initialize a queue and add the starting position of the ball.
  2. Use a set to track visited positions to a...

Submit Your Answer
Markdown supported

Related Questions