1732. Find the Highest Altitude 發表於 2023-12-21 | 分類於 leetcode problemsolution123456789101112class Solution {public: int largestAltitude(vector<int>& gain) { int mx_height = 0; int cur_height = 0; for(int g:gain){ cur_height += g; mx_height = max(mx_height, cur_height); } return mx_height; }}; analysis time complexity O(n) space complexity O(1)