Skip to content

Practice Check if There Is a Valid Parentheses String Path

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2267
LeetCode Problem

Check if There Is a Valid Parentheses String Path

Problem Statement

Starting at the top-left cell of grid, move only right or down to the bottom-right cell. Read each visited parenthesis in order. Return whether some such path forms a balanced string: every closing parenthesis must match an earlier opening parenthesis and none may remain unmatched.

Source: Check if There Is a Valid Parentheses String Path on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
grid = [["(","(","("],[")","(",")"],["(","(",")"],["(","(",")"]]
Output
true

# Example 2

Input
grid = [[")",")"],["(","("]]
Output
false

Constraints

m == grid.length
n == grid[i].length
1 <= m, n <= 100
grid[i][j] is either '(' or ')'.

Related LeetCode Problems

Practice more problems similar to Check if There Is a Valid Parentheses String Path.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.