Files
LeetCode-Go/leetcode/1732.Find-the-Highest-Altitude/1732. Find the Highest Altitude.go

13 lines
175 B
Go

package leetcode
func largestAltitude(gain []int) int {
max, height := 0, 0
for _, g := range gain {
height += g
if height > max {
max = height
}
}
return max
}