[LeetCode] 1732. Find the Highest Altitude

Chobby·2025년 10월 10일
1

LeetCode

목록 보기
590/650

😎풀이

  1. gain 순회
    1-1. 현재 점수 누적
    1-2. 최대 점수 갱신
  2. 최대 점수 반환환
function largestAltitude(gain: number[]): number {
    let highScore = 0
    let curScore = 0
    for(const score of gain) {
        curScore += score
        highScore = Math.max(highScore, curScore)
    }
    return highScore
};
profile
내 지식을 공유할 수 있는 대담함

0개의 댓글