[LeetCode] 3285. Find Indices of Stable Mountains

Chobby·5일 전

LeetCode

목록 보기
886/907

😎풀이

  1. 안정적인 산은 가장 인접한 이전 산이 임계 높이를 초과할 경우 인정됨
  2. 안정적인 산의 인덱스 목록 반환
function stableMountains(height: number[], threshold: number): number[] {
    const stable = []
    for(let i = 1; i < height.length; i++) {
        const prev = height[i - 1]
        if(prev > threshold) stable.push(i)
    }
    return stable
};
profile
내 지식을 공유할 수 있는 대담함

0개의 댓글