Google | L3 | Telephonic Screening Round | Hyderabad
Anonymous User
816

Given an array of integers representing the heights of different wall sections, you can paint using horizontal or vertical strokes.

One stroke means you move the brush without lifting it in either direction (horizontally or vertically).

You need to minimize the number of strokes required to fully paint the wall.
heights = [3,1,2,2,2]
Ans: 3

heights = [3,2,4,1,4,2,1]
Ans: 6

image.png

Comments (11)