Completely Passable Grid Rows and Columns
Problem statement
A rectangular board contains 0 for a passable cell and + for an obstacle. Return the rows and columns that are completely passable: every cell in each returned row or column must be 0.
For this exercise, assume grid contains one string per row. Return exactly two integer arrays: first the row indices, then the column indices. Indices are zero-based and each array is in increasing order. Either array may be empty.
Function
passableLines(grid: String[]) → int[][]Examples
Example 1
grid = ["000","+00","000"]return = [[0,2],[1,2]]Rows 0 and 2 and columns 1 and 2 contain only zeroes.
Example 2
grid = ["0+","+0"]return = [[],[]]Every row and column contains an obstacle.
Example 3
grid = ["0"]return = [[0],[0]]The single passable cell makes both its row and column completely passable.
Constraints
- For this exercise, assume
1 <= grid.length <= 30and each row has the same length from1through30. - Every cell is
0or+.