swift: add «1732. Find the Highest Altitude»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
00e0063e1e
commit
9bebfc43ba
1 changed files with 13 additions and 0 deletions
13
swift/find-the-highest-altitude.swift
Normal file
13
swift/find-the-highest-altitude.swift
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue