Tap here to switch tabs
Problem
Submissions

Problem: Check for a Path With Equal Number of 0s and 1s

Try to solve the Check for a Path With Equal Number of 0s and 1s problem.

Statement

You are given an m $ imes$ n binary grid grid. You start at the top left cell (0,0)(0, 0) and wish to reach the bottom right cell (m−1,n−1)(m - 1, n - 1). From any cell, you may only move either right or down.

Return true if there is a path from (0,0)(0, 0) to (m−1,n−1)(m - 1, n - 1) that visits an equal number of 00’s and 11’s, or false otherwise.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 2≤2 \leq m, n ≤100\leq 100

  • grid[i][j] is either 00 or 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check for a Path With Equal Number of 0s and 1s

Try to solve the Check for a Path With Equal Number of 0s and 1s problem.

Statement

You are given an m $ imes$ n binary grid grid. You start at the top left cell (0,0)(0, 0) and wish to reach the bottom right cell (m−1,n−1)(m - 1, n - 1). From any cell, you may only move either right or down.

Return true if there is a path from (0,0)(0, 0) to (m−1,n−1)(m - 1, n - 1) that visits an equal number of 00’s and 11’s, or false otherwise.

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 2≤2 \leq m, n ≤100\leq 100

  • grid[i][j] is either 00 or 11.