
-Code
class Solution {
public int largestAltitude(int[] gain) {
int nowHeight = 0;
int maxHegiht = 0;
for (int height : gain) {
nowHeight += height;
maxHegiht = Math.max(maxHegiht, nowHeight);
}
return maxHegiht;
}
}'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
| [LeetCode/Java] Find the Difference of Two Arrays (0) | 2025.12.31 |
|---|---|
| [LeetCode/Java] Find Pivot Index (0) | 2025.12.31 |
| [LeetCode/Java] Maximum Average Subarray I (0) | 2025.12.31 |
| [LeetCode/Java] Is Subsequence (0) | 2025.12.31 |
| [LeetCode/Java] Move Zeroes (0) | 2025.12.31 |