[Leet Code] Find the Highest Altitude

Input: gain = [-5,1,5,0,-7]
Output: 1
Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.
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
class Solution(object):
def largestAltitude(self, gain):
"""
:type gain: List[int]
:rtype: int
"""
start = 0
highest = 0
for i in gain:
start += i
if start > highest:
highest = start
return highest

--

--

--

Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.

Google hype, YouTube and Google Earth Projects

Docker-compose for React, changes reflect real-time inside a container

A Short Guide To Static And Dynamic Libraries

Modern Data Pipelines with Azure Synapse Analytics and Azure Purview

How to add security camera to stealth game in Unity

Guides on how to use Facebook login kit on Android apps — Ekene Christian.

Object oriented programming in Java

AWS Lambda

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew Boyd

Matthew Boyd

Learning, and posting my findings!

More from Medium

Origin and Evolution of Algorithms

Algorithms for Beginners

Longest Consecutive Sequence

LeetCode 1. Two Sum

Two Sum