C++/Python| One Line | Prefix Sum | One Pass | O(N)🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nStore the perfix sum  int the array and return max elemnt in prefix array . But if all 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nStore the perfix sum  int the array and return max elemnt in prefix array . But if all are negative so we have toreturn 0 . So return `max(0,max_elem);`\n# Approach\n<!-- Describe your approach to solving the problem. -->\nPrefix Sum\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n**C++**\n```\nclass Solution {\npublic:\n    int largestAltitude(vector<int>& gain) {\n         for(int i=1;i<gain.size();i++)gain[i]=gain[i-1]+gain[i];\n         return max(0,*max_element(gain.begin(),gain.end()));\n    }\n};\n```\n**Python**\n```\ndef largestAltitude(self, A):\n        return max(0, max(accumulate(A)))\n\n```\n
['Array', 'Prefix Sum', 'C++']