Class Solution
java.lang.Object
g1701_1800.s1732_find_the_highest_altitude.Solution
1732 - Find the Highest Altitude.<p>Easy</p>
<p>There is a biker going on a road trip. The road trip consists of <code>n + 1</code> points at different altitudes. The biker starts his trip on point <code>0</code> with altitude equal <code>0</code>.</p>
<p>You are given an integer array <code>gain</code> of length <code>n</code> where <code>gain[i]</code> is the <strong>net gain in altitude</strong> between points <code>i</code> and <code>i + 1</code> for all (<code>0 <= i < n)</code>. Return <em>the <strong>highest altitude</strong> of a point.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> gain = [-5,1,5,0,-7]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong> The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> gain = [-4,-3,-2,-1,4,3,2]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0.</p>
<p><strong>Constraints:</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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
largestAltitude
public int largestAltitude(int[] gain)
-