C++ Solution  || Easy to Understand || Prefix Sum
Intuition\nThe description of the problem is not very clear. I recommned you to see the test cases 2-3 times & you will be able to understand the probelem.\n\n#
# Intuition\nThe description of the problem is not very clear. I recommned you to **see the test cases 2-3 times** & you will be able to understand the probelem.\n\n# Approach\n keep on finding prefix sum\n\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```\nclass Solution {\npublic:\n    int largestAltitude(vector<int>& gain) {\n        int n = gain.size();\n        int prefixSum = 0 ;\n        int ans = -1e9;\n        for(int i =1;i<=n;i++){\n              prefixSum +=  gain[i-1];\n              ans = max( ans , prefixSum);\n        }\n        if(ans < 0) return 0;\n      return ans;\n    }\n};\n```
['Array', 'Prefix Sum', 'C++']