<p>You are given an integer array <code>target</code>. You have an integer array <code>initial</code> of the same size as <code>target</code> with all elements initially zeros.</p>

<p>In one operation you can choose <strong>any</strong> subarray from <code>initial</code> and increment each value by one.</p>

<p>Return <em>the minimum number of operations to form a </em><code>target</code><em> array from </em><code>initial</code>.</p>

<p>The test cases are generated so that the answer fits in a 32-bit integer.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> target = [1,2,3,2,1]
<strong>Output:</strong> 3
<strong>Explanation:</strong> We need at least 3 operations to form the target array from the initial array.
[<strong><u>0,0,0,0,0</u></strong>] increment 1 from index 0 to 4 (inclusive).
[1,<strong><u>1,1,1</u></strong>,1] increment 1 from index 1 to 3 (inclusive).
[1,2,<strong><u>2</u></strong>,2,1] increment 1 at index 2.
[1,2,3,2,1] target array is formed.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> target = [3,1,1,2]
<strong>Output:</strong> 4
<strong>Explanation:</strong> [<strong><u>0,0,0,0</u></strong>] -&gt; [1,1,1,<strong><u>1</u></strong>] -&gt; [<strong><u>1</u></strong>,1,1,2] -&gt; [<strong><u>2</u></strong>,1,1,2] -&gt; [3,1,1,2]
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> target = [3,1,5,4,2]
<strong>Output:</strong> 7
<strong>Explanation:</strong> [<strong><u>0,0,0,0,0</u></strong>] -&gt; [<strong><u>1</u></strong>,1,1,1,1] -&gt; [<strong><u>2</u></strong>,1,1,1,1] -&gt; [3,1,<strong><u>1,1,1</u></strong>] -&gt; [3,1,<strong><u>2,2</u></strong>,2] -&gt; [3,1,<strong><u>3,3</u></strong>,2] -&gt; [3,1,<strong><u>4</u></strong>,4,2] -&gt; [3,1,5,4,2].
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= target.length &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= target[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def minNumberOperations(self, target: List[int]) -> int:
        count = 0
        prev = 0
        for curr in target:
            if curr>prev:
                count+=curr-prev
            prev = curr
        return count
    
    """
    Imagine that the numbers in the target array are houses built of wooden blocks of height arr[i] standing wall to wall and you are standing to the west of this line of wooden houses.
Your aim is to burn down every block of each house ( i.e smashing down the target array to all zeros array)
You have a flamethrower.
If you fire, the flames burn everything as far as it finds wood.
The wooden building will lose 1 lower block each time you fire and the fire reaches its base.
The building will still stand on the remaining blocks it will just get shorter.
Now, we have to find how many times we need to fire the flame.
For example,

we have 5 buildings [1,3,2,5,2]

a) Total flames = 0
Since you are on the left side, you see you have a house of 1 block, so you fire once.
Total flames = 0 + 1 = 1
This flame wipes out the lower base of every house as there was wood to burn.

b) Now, houses look like [0, 2, 1, 4, 1]
0 is ground so you can now see a 2 block house in front of you. So you fire twice to burn it to the ground.
Total flames = 1 + 2 = 3
Here, the first flame will burn lower level of each of the last 4 houses. [0, 1, 0, 3, 0]. But, the second flame will not be able to pass beyond 2nd house because there is no more contiguous wood. So, the second flame here will burn down only the last remaining block of the 2nd house.

c) Now, houses look like [0, 0, 0, 3, 0]
You see a building of 3 blocks. So you now need at least 3 flames to burn down this house.
Total flames = 3 + 3 = 6.

Now, you don't see any houses. You are satisfied.
    """
26500