https://leetcode.com/problems/find-the-highest-altitude/description/
有一個自行車手從高度為0的位置開始騎車,他要經過 n 個點,每個點的海拔
距離上個點為 gain[i],求出他騎到終點後最高海拔是多少。
Example 1:
Input: gain = [-5,1,5,0,-7]
Output: 1
Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.
Example 2:
Input: gain = [-4,-3,-2,-1,4,3,2]
Output: 0
Explanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0.
思路:
1.從0開始不斷計算新的點的海拔高度,並更新最大值。
Java Code: