Problem · Matrix

Minimum Obstacle Removal

Learn this problem
MediumUber logoUberFULLTIMEOA
See Uber hiring insights

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

drafts saved locally
public int minimumObstacleRemoval(String[][] matrix) {
  // write your code here
}
matrix[["*", "*", "*", "*"], ["#", "*", ".", "*"], [".", ".", "#", "."], [".", "#", ".", "#"]]
expected4
checking account