KimMinJun
Coding Note
KimMinJun
전체 방문자
오늘
어제
  • 분류 전체보기 (486)
    • ALGORITHM (11)
      • 정렬 (6)
      • 최단경로 (1)
      • 자료구조 (1)
      • 슬라이딩 윈도우 (1)
      • etc (2)
    • Git (5)
    • Web (24)
      • Vanilla JS (13)
      • TS (2)
      • React (7)
      • ETC (1)
    • React 공식문서 (번역, 공부) (11)
      • Quick Start (2)
      • Installation (0)
      • Describing the UI (9)
      • Adding Interactivity (0)
      • Managing State (0)
      • Escape Hatches (0)
    • Next.js 공식문서 (번역, 공부) (3)
      • Getting Started (2)
      • Building Your Application (1)
    • PS (431)
      • 백준 (187)
      • Programmers (104)
      • CodeUp (21)
      • STL (3)
      • 제코베 JS 100제 (50)
      • SWEA (0)
      • LeetCode (65)
    • IT (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • 관리

공지사항

인기 글

태그

  • Level 1
  • 제코베 JS 100제
  • Level1
  • 문자열
  • 정렬
  • string
  • LeetCode
  • Level 0
  • codeup
  • C++
  • C
  • 백준
  • 그래프
  • tree
  • js
  • programmers
  • recursion
  • 수학
  • Level 2
  • 다이나믹 프로그래밍

최근 댓글

최근 글

hELLO · Designed By 정상우.
KimMinJun

Coding Note

PS/LeetCode

LeetCode / Array / 1732번 / Find the Highest Altitude / JS

2023. 6. 21. 19:03

< 문제 바로가기 >

 

Find the Highest Altitude - LeetCode

Can you solve this real interview question? Find the Highest Altitude - There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integ

leetcode.com

 

< 문제 간단설명 >

고도들이 배열로 주어지는데, 고도들을 따라 계속해서 이동했을 때(누적 합), 가장 고도가 높은 곳의 고도를 반환하면 된다.

 

/**
 * @param {number[]} gain
 * @return {number}
 */
var largestAltitude = function(gain) {
    let altitude = 0;
    let altitudeList = [0];
    
    for(let i=0; i<gain.length; i+=1) {
      altitude += gain[i];
      altitudeList.push(altitude);
    }

    return Math.max(...altitudeList);
};
저작자표시 (새창열림)

'PS > LeetCode' 카테고리의 다른 글

LeetCode / Array / 1582번 / Special Positions in a Binary Matrix / JS  (0) 2023.12.13
LeetCode / Array / 2090번 / K Radius Subarray Averages / JS  (0) 2023.06.21
LeetCode / Tree / 1161번 / Maximum Level Sum of a Binary Tree / JS  (0) 2023.06.17
LeetCode / Tree / 530번 / Minimum Absolute Difference in BST / JS  (0) 2023.06.17
    'PS/LeetCode' 카테고리의 다른 글
    • LeetCode / Array / 1582번 / Special Positions in a Binary Matrix / JS
    • LeetCode / Array / 2090번 / K Radius Subarray Averages / JS
    • LeetCode / Tree / 1161번 / Maximum Level Sum of a Binary Tree / JS
    • LeetCode / Tree / 530번 / Minimum Absolute Difference in BST / JS
    KimMinJun
    KimMinJun

    티스토리툴바