PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers

Quick Overview

This question evaluates understanding of graph traversal and reachability in grid-based pathfinding, covering skills such as modeling a 2D grid as a graph, handling obstacles and boundary conditions, and algorithmic traversal strategies.

  • medium
  • Roblox
  • Coding & Algorithms
  • Software Engineer

Can the character reach the destination?

Company: Roblox

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You control a character starting at a start cell and want to reach a target cell in a 2D grid. Some cells are blocked by obstacles and cannot be entered. Given a grid of size m x n containing: - 'S' = start (exactly one) - 'T' = target (exactly one) - '#' = obstacle (cannot step on) - '.' = free cell The character may move one step at a time in 4 directions (up, down, left, right) and must stay within the grid. Return whether it is possible to reach 'T' starting from 'S'.

Quick Answer: This question evaluates understanding of graph traversal and reachability in grid-based pathfinding, covering skills such as modeling a 2D grid as a graph, handling obstacles and boundary conditions, and algorithmic traversal strategies.

You are given a 2D grid representing a map. There is exactly one start cell 'S' and exactly one target cell 'T'. Some cells contain obstacles '#', which cannot be entered, and free cells are marked with '.'. The character starts at 'S' and can move one step at a time in four directions: up, down, left, and right. The character must stay inside the grid and cannot move onto obstacle cells. Return whether it is possible to reach 'T' starting from 'S'.

Constraints

  • 1 <= m, n
  • All rows in grid have the same length
  • grid[i][j] is one of 'S', 'T', '#', or '.'
  • Exactly one 'S' and exactly one 'T' exist in the grid

Examples

Input: (["S..", ".#.", "..T"],)

Expected Output: True

Explanation: A valid path exists around the obstacle: down, down, right, right.

Input: (["S#.", "##.", "..T"],)

Expected Output: False

Explanation: The start cell is completely blocked by obstacles, so no movement is possible.

Input: (["ST"],)

Expected Output: True

Explanation: This single-row edge case is reachable immediately by moving one step to the right.

Input: (["S#..", ".#.#", ".#T#", "...."],)

Expected Output: True

Explanation: Although direct paths are blocked, the character can go around through the bottom row to reach T.

Input: (["S", ".", "#", "T"],)

Expected Output: False

Explanation: In this single-column edge case, the obstacle blocks the only route to the target.

Hints

  1. Think of each open cell as a node in a graph connected to its up, down, left, and right neighbors.
  2. Use BFS or DFS and keep track of visited cells so you do not process the same cell multiple times.
Last updated: May 5, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Implement Sliding-Window Rate Limiter - Roblox (medium)
  • Find target-heavy sliding windows - Roblox (medium)
  • Find most frequent call path in logs - Roblox (medium)
  • Track Highest-Earning Experience - Roblox (medium)
  • Find the Most Frequent Log Call - Roblox (easy)