cs: add “1732. Find the Highest Altitude”
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
30202920b0
commit
ccd80cc46b
1 changed files with 13 additions and 0 deletions
13
cs/find-the-highest-altitude.cs
Normal file
13
cs/find-the-highest-altitude.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
public class Solution {
|
||||||
|
public int LargestAltitude(int[] gain) {
|
||||||
|
int m = 0;
|
||||||
|
int alt = 0;
|
||||||
|
|
||||||
|
foreach (var d in gain) {
|
||||||
|
alt += d;
|
||||||
|
m = Math.Max(m, alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue