class Solution {
public int largestAltitude(int[] gain) {
int start =0;
int highest = 0;
for(int i = 0; i < gain.length; i++) {
start += gain[i];
if (start > highest) {
highest = start;
}
}
return highest;
}
}
'코딩테스트' 카테고리의 다른 글
[leetcode] 841. Keys and Rooms (0) | 2024.05.26 |
---|---|
[leetcode] 104. Maximum Depth of Binary Tree (0) | 2024.05.23 |
[leetcode] 643. Maximum Average Subarray I (0) | 2024.05.18 |
[leetcode] 392. Is Subsequence (0) | 2024.05.18 |
[leetcode] 1431. Kids With the Greatest Number of Candies (0) | 2024.05.18 |