Problem · Array

Completely Passable Grid Lines

Learn this problem
EasySplunk logoSplunkFULLTIMEPHONE SCREEN

Problem statement

You are given a non-empty rectangular grid of characters. A 0 is passable and a + is impassable.

Return a two-element list. Its first list contains, in increasing order, every zero-based row index whose cells are all passable. Its second list contains, in increasing order, every zero-based column index whose cells are all passable.

Function

passableLines(grid: String[]) → List<List<Integer>>

Examples

Example 1

grid = ["000","0+0","000"]return = [[0,2],[0,2]]

Rows 0 and 2 and columns 0 and 2 contain only passable cells.

Example 2

grid = ["++","++"]return = [[],[]]

No row or column is completely passable.

Constraints

  • 1 <= grid.length.
  • 1 <= grid[i].length.
  • Every row has the same length.
  • The grid contains at most 4,096 cells.
  • Every cell is 0 or +.

More Splunk problems

drafts saved locally
public java.util.List<java.util.List<Integer>> passableLines(String[] grid) {
    // Return [passableRows, passableColumns].
}
grid["000","0+0","000"]
expected[[0,2],[0,2]]
checking account