one liner + detailed solution | Python
Hi!\nPlease comment if you have questions or suggestions regarding this post!\nPlease upvote if you find this post interesting!\n\n# one liner\n\nclass Solution
# Hi!\nPlease **comment** if you have questions or suggestions regarding this post!\nPlease **upvote** if you find this post interesting!\n\n# one liner\n```\nclass Solution:\n    def largestAltitude(self, gain: List[int]) -> int:\n        return max(*accumulate(gain), 0)\n```\n# detailed Solution\n```\nclass Solution:\n    def largestAltitude(self, gain: List[int]) -> int:\n        res = s = 0\n        for v in gain:\n            s += v\n            res = max(res, s)\n        return res\n```\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(1)
['Array', 'Iterator', 'Python', 'Python3']