1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00

swift: add «1732. Find the Highest Altitude»

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-06-01 23:46:10 +02:00
parent 00e0063e1e
commit 9bebfc43ba
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,13 @@
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
}
}