https://leetcode.com/problems/find-indices-of-stable-mountains/description/
1
2
3
4
5
6
7
8
|
class Solution:
def stableMountains(self, height: List[int], threshold: int) -> List[int]:
answer = []
for i in range(1, len(height)):
if height[i - 1] > threshold:
answer.append(i)
return answer
|
cs |
height 리스트를 순차 탐색하면서 바로 직전 값이 threshold보다 큰 경우 정답 리스트에 넣는 방식으로 구현
반응형
'python-algorithm' 카테고리의 다른 글
3194. Minimum Average of Smallest and Largest Elements (0) | 2024.09.21 |
---|---|
3232. Find if Digit Game Can Be Won (0) | 2024.09.21 |
3190. Find Minimum Operations to Make All Elements Divisible by Three (0) | 2024.09.19 |
leetcode 3280. Convert Date to Binary (1) | 2024.09.12 |
leetcode 1684. Count the Number of Consistent Strings (0) | 2024.09.12 |
댓글