2 Easy Solutions🔥 || C++🔥 || Fastest🔥🔥🔥
\n# Approach : Brute Force\n Describe your approach to solving the problem. \n\n# Code 1\n\nclass Solution {\npublic:\n    int largestAltitude(vector<int>& gain
\n# Approach : Brute Force\n<!-- Describe your approach to solving the problem. -->\n\n# Code 1\n```\nclass Solution {\npublic:\n    int largestAltitude(vector<int>& gain) {\n        \n        int altitude=0,max=0;\n        for(int i=0;i<gain.size();i++){\n            altitude=altitude+gain[i];\n\t\t\t\n            if(max<altitude)\n                max=altitude;\n        }\n       return max;\n    }\n};\n```\n\n# Approach: Using Vector\n<!-- Describe your approach to solving the problem. -->\n\n# Code 2\n```\nclass Solution {\npublic:\n    int largestAltitude(vector<int>& gain) {\n        \n        vector<int> v;\n        v.push_back(0);\n        int mx =0;\n        for(int i =0; i<gain.size(); i++){\n            int s = v[i];\n            v.push_back(gain[i]+s);\n            if(mx<v[i+1]){\n                mx = v[i+1];\n            }\n        }\n        \n        for(int i =0; i<v.size(); i++){\n            cout<<v[i]<<" ";\n        }\n        \n        cout<<endl;\n        \n       return mx; \n    }\n};\n```
['C++']