CPP || O(N)
\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\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    {\n        int high = 0;\n        for(int i=0;i<gain.size();i++) \n        {\n            if(i==0)\n            { \n                if(high<gain[i])\n                {\n                    high=gain[i];\n                }\n            }\n            else\n            {\n                gain[i]+=gain[i-1];\n                if(high<gain[i])\n                {\n                    high=gain[i];\n                }\n            }\n        }    \n        return high;\n    }\n};\n```
['C++']