1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 09:59:41 +01:00
LeetCode/swift/find-the-highest-altitude.swift

14 lines
214 B
Swift
Raw Normal View History

class Solution {
func largestAltitude(_ gain: [Int]) -> Int {
var m = 0
var alt = 0
for d in gain {
alt += d
m = max(m, alt)
}
return m
}
}