Skip to content

Commit

Permalink
Time: 0 ms (100%), Space: 2.4 MB (57.43%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Sep 27, 2024
1 parent f8cb71f commit d4d30f8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions 1732-find-the-highest-altitude/1732-find-the-highest-altitude.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
func largestAltitude(gain []int) int {
res, cur := 0, 0
ans := 0
road := 0
for _, v := range gain {
cur += v
if res < cur {
res = cur
road += v
if ans < road {
ans = road
}
}

return res
return ans
}

0 comments on commit d4d30f8

Please sign in to comment.