A level editor checks how many walls a player must knock down to get from the top-left cell to the bottom-right cell. The level is a grid of strings where "." is open floor and "#" is a wall. Players move up, down, left, or right. Stepping onto open floor is free; stepping onto a wall means knocking it down, which costs 1.
Write fewestBreaks(level) that returns the smallest number of walls that must be knocked down. The top-left and bottom-right cells are always open.
Input: level = [".#.",".#.",".#."] Output: 1
The middle column is a solid wall, so at least one wall must go. Knocking down any one of them opens a path.
Input: level = ["..",".."] Output: 0
The floor is already open from corner to corner.
1 <= level.length, level[i].length <= 200level[0][0] and the bottom-right cell are ".".Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #436 Fewest Walls to Knock Down. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.