FastPrepCompletely Passable Grid Rows and Columns

Completely Passable Grid Rows and Columns

Walmart logoWalmart● EasyFULLTIMEPHONE SCREEN
Learn

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 <= 30 and each row has the same length from 1 through 30.
  • Every cell is 0 or +.

More Walmart problems

See Walmart hiring insights
public int[][] passableLines(String[] grid) {
    // Write your code here.
    return new int[][]{new int[0],new int[0]};
}
grid["000","+00","000"]
expected[[0,2],[1,2]]
Checking account…