Skip to content

Problem 1: Highest altitude

Course: Intro Class 2- DSA - chapter 3

Link: https://leetcode.com/problems/find-the-highest-altitude/description/

Let’s say you are at xth point. What is your altitude right now?

It is gain[0] + gain[1] + gain[2] + .. + gain[x-1]. Let’s call it altitude[x]

What is maximum altitude point? It is Max(altitude[i]).

So we can create altitude[] using prefix sum and find the maximum altitude point.