https://leetcode.com/problems/find-the-peaks/description/
Find the Peaks - LeetCode
Can you solve this real interview question? Find the Peaks - You are given a 0-indexed array mountain. Your task is to find all the peaks in the mountain array. Return an array that consists of indices of peaks in the given array in any order. Notes: * A p
leetcode.com
1 2 3 4 5 6 7 8 9 | class Solution: def findPeaks(self, mountain: List[int]) -> List[int]: answer = [] for i in range(1, len(mountain) - 1): if mountain[i-1]< mountain[i] and mountain[i] > mountain[i+1]: answer.append(i) return answer | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2928. Distribute Candies Among Children I (0) | 2023.12.27 |
---|---|
leetcode CodeTestcaseTestcaseTest Result2942. Find Words Containing Character (0) | 2023.12.27 |
leetcode 2956. Find Common Elements Between Two Arrays (0) | 2023.12.27 |
leetcode 2965. Find Missing and Repeated Values (0) | 2023.12.27 |
백준 4388 받아올림 (0) | 2023.12.27 |
댓글