Back to June Back to Year 2026
EASY 19 Jun 2026 View on LeetCode

1732. Find the Highest Altitude

</> Solution

/**
 * Problem: LeetCode 1732 - Find the Highest Altitude
 * Difficulty: Easy
 * Language: Java
 * Author: CodeByTushu
 */
class Solution {
    public int largestAltitude(int[] gain) {
        int altitude = 0;
        int maxAltitude = 0;
        for (int g : gain) {
            altitude += g;
            maxAltitude = Math.max(maxAltitude, altitude);
        }
        return maxAltitude;
    }
}

TIME COMPLEXITY

O(N)

SPACE COMPLEXITY

O(1)

TOPICS

Array Prefix Sum