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