Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Find the Highest Altitude

Easy

Topics
ArrayPrefix Sum

A biker starts at altitude 0. gain[i] is the net gain between point i and i+1. Return the highest altitude reached.

Example 1

Input:  gain = [-5,1,5,0,-7]
Output: 1

Example 2

Input:  gain = [-4,-3,-2,-1,4,3,2]
Output: 0

Constraints

  • 1 <= gain.length <= 100
  • -100 <= gain[i] <= 100
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access