Re: [閒聊] 每日LeetCode

作者: Rushia (みけねこ的鼻屎)   2023-06-19 21:12:06
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:
作者: JIWP (JIWP)   2022-06-19 21:12:00
大師你不是都hard起手
作者: Rushia (みけねこ的鼻屎)   2023-06-19 21:13:00
我hard題數只有20 對不起

Links booklink

Contact Us: admin [ a t ] ucptt.com