← 返回 capitalone 的题目列表Minimum Obstacles to Brick Drop
类型:online_judge
Given a matrix containing three types of elements: blocks, empty spaces, and obstacles. The blocks are connected. When they fall down, calculate the minimum number of obstacles that must be removed for the block to reach the bottom of the matrix.
Input:
A 2D list where:
& indicates a block
_ indicates an empty space
* indicates an obstacle
Example:
input = [
[&,&,&,&],
[&,&, _ , _],
[*, _ , * , _]
]
Output:
The minimum number of obstacles that need to be removed.
For example, the output of the above input example is 1, with the obstacle at the bottom-left needing removal.
Example
Input
5
&&&&
&&__
*_*_