Simple trick!
IntuitionEach value in the gain array represents the net gain in altitude between two points. If we start at altitude 0, we can calculate the altitude after eac
# Intuition
Each value in the gain array represents the net gain in altitude between two points. If we start at altitude 0, we can calculate the altitude after each gain by summing it with the previous altitude.

We need to find the maximum altitude reached during this journey.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
1.Initialize a list n with the starting altitude 0.

2.Loop through each gain[i], and compute the current altitude by adding it to the last value in n.

3.Append this new altitude to n.

4.Finally, return the maximum value in n.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:$$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:$$O(n)$$

<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def largestAltitude(self, gain: List[int]) -> int:
        n=[0]
        for i in range(len(gain)):
            
            n.append(n[-1]+gain[i])

        return max(n)

```
![UPVOTE.png](https://assets.leetcode.com/users/images/c8a8e5c8-c015-44ec-892d-936c8bdfe768_1743744710.7959058.png)
['Python3']