Practice Check if There is a Valid Path in a Grid
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Check if There is a Valid Path in a Grid
Problem Statement
Each grid cell contains one street type: 1 connects left and right, 2 up and down, 3 left and down, 4 right and down, 5 left and up, and 6 right and up. Moving between neighboring cells is permitted only when their street openings connect across the shared edge. Without changing any street, determine whether a path exists from (0, 0) to (m - 1, n - 1). Return true if it does and false otherwise.
Source: Check if There is a Valid Path in a Grid on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
grid = [[2,4,3],[6,5,2]]
true
# Example 2
grid = [[1,2,1],[1,2,1]]
false
# Example 3
grid = [[1,1,2]]
false
Constraints
Related LeetCode Problems
Practice more problems similar to Check if There is a Valid Path in a Grid.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.