Description
Solutions
Array Transformation Steps (Early Career)
π₯ FULLTIMEπRELATED PROBLEMS
You are given an array, and the task is to determine how many steps it takes to transform an array of all zeros into the given array. In each step, you can add a contiguous sequence of 1's to the array.
Example 1:
Input: array = [2, 1, 0, 2]
Output: 4
Explanation:The transformation can be done in 4 steps as follows:
- 0000 -> 1100: Add a contiguous sequence of 1's covering the first two elements.
- 1100 -> 2100: Add a contiguous sequence of 1's covering the first element.
- 2100 -> 2101: Add a contiguous sequence of 1's covering the fourth element.
- 2101 -> 2102: Add a contiguous sequence of 1's covering the fourth element again.
Constraints:
π»ββοΈπ»ββοΈ

Related Problems
Testcase
Result
Case 1
input:
output: