FastPrepMinimum Obstacle Removal

Minimum Obstacle Removal

Uber logoUber● MediumFULLTIMEOA
Learn

Problem statement

You are given a 2d matrix which consist of the following symbols ".", "#", "|", where "." represent free cell, "#" represent a obstacle, "|" denotes shape. Your task is to find out the minimum obstacle to remove from the matrix so that the shapes falls down to the bottom.

Function

minimumObstacleRemoval(matrix: String[][]) → int

Examples

Example 1

matrix = [["*", "*", "*", "*"], ["#", "*", ".", "*"], [".", ".", "#", "."], [".", "#", ".", "#"]]return = 4
Example 1 illustration

Hence, return 4.

More Uber problems

See Uber hiring insights
public int minimumObstacleRemoval(String[][] matrix) {
  // write your code here
}
matrix[["*", "*", "*", "*"], ["#", "*", ".", "*"], [".", ".", "#", "."], [".", "#", ".", "#"]]
expected4
Checking account…