-Code
def count_peaks(heights):
peaks = 0
for i in range(1, len(heights) - 1):
if heights[i - 1] < heights[i] > heights[i + 1]:
peaks += 1
return peaks
for t in range(1, int(input()) + 1):
n = int(input())
heights = list(map(int, input().split()))
res = count_peaks(heights)
print(f"Case #{t}: {res}")
'Beakjoon&프로그래머스 > 파이썬' 카테고리의 다른 글
[백준/파이썬] 30886번 Artistic Souvenir (0) | 2023.11.30 |
---|---|
[백준/파이썬] 26145번 출제비 재분배 (0) | 2023.11.29 |
[백준/파이썬] 25830번 Microwave Mishap (0) | 2023.11.27 |
[백준/파이썬] 25933번 Medal Ranking (2) | 2023.11.26 |
[백준/파이썬] 29895번 Jõululaul (1) | 2023.11.25 |