diff --git a/swift/find-the-highest-altitude.swift b/swift/find-the-highest-altitude.swift new file mode 100644 index 0000000..261a989 --- /dev/null +++ b/swift/find-the-highest-altitude.swift @@ -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 + } +}