Algorithm · Google · Hard
Requirements Input: an integer n together with an array a[1..n], where a[i] gives the height of plank i. You may use either of the following painting actions, each with cost 1: Vertical stroke: paint a single entire plank, from its base through its full height. Horizontal stroke: choose a level h and a consecutive interval [l, r], then paint that row across the interval. This is permitted only when a[i] >= h for all $$i \in [l, r]$$. Output: return the smallest number of…
Checking your access…