1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/找到最高海拔 [find-the-highest-altitude].html
2022-03-29 12:43:11 +08:00

32 lines
1.1 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>有一个自行车手打算进行一场公路骑行,这条路线总共由 <code>n + 1</code> 个不同海拔的点组成。自行车手从海拔为 <code>0</code> 的点 <code>0</code> 开始骑行。</p>
<p>给你一个长度为 <code>n</code> 的整数数组 <code>gain</code> ,其中 <code>gain[i]</code> 是点 <code>i</code> 和点 <code>i + 1</code> 的 <strong>净海拔高度差</strong><code>0 <= i < n</code>)。请你返回 <strong>最高点的海拔</strong></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>gain = [-5,1,5,0,-7]
<b>输出:</b>1
<b>解释:</b>海拔高度依次为 [0,-5,-4,1,1,-6] 。最高海拔为 1 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>gain = [-4,-3,-2,-1,4,3,2]
<b>输出:</b>0
<b>解释:</b>海拔高度依次为 [0,-4,-7,-9,-10,-6,-3,-1] 。最高海拔为 0 。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == gain.length</code></li>
<li><code>1 <= n <= 100</code></li>
<li><code>-100 <= gain[i] <= 100</code></li>
</ul>