Prefix_Sum.py
Approach\nPrefix Sum\n# Complexity\n- Time complexity:\n O(n)\n\n# Code\n\nclass Solution:\n    def largestAltitude(self, gain: List[int]) -> int:\n        l=[0
# Approach\nPrefix Sum\n# Complexity\n- Time complexity:\n $$O(n)$$\n\n# Code\n```\nclass Solution:\n    def largestAltitude(self, gain: List[int]) -> int:\n        l=[0]\n        for i in range(len(gain)):l.append(l[i]+gain[i])\n        return max(l)\n```\n![](https://i.redd.it/iwj7ej9xwdp91.jpg)
['Math', 'Prefix Sum', 'Python3']