Candidate | Softeer Assessment UI
softeer.ai
나의 코드
import sys
input = sys.stdin.readline
m_ct = int(input().strip())
m_list = list(map(int, input().split()))
# 최솟값 변수양의 무한대로 초기값
min_length = float('inf')
min_count = 0
for i in range(1, m_ct):
now_value = abs(m_list[i] - m_list[i - 1])
if now_value < min_length:
min_length = now_value
min_count = 1
elif now_value == min_length:
min_count += 1
print(min_count)
오늘 배운것 : 최솟값 변수 양의 무한대로 초기화
초기변수명=float('inf')
'코딩테스트 파이썬 > 파이썬 프로그래머스 3단계' 카테고리의 다른 글
| Softeer 연습문제(3단계) - 성적 평균 (0) | 2024.06.24 |
|---|---|
| Softeer 연습문제(3단계) - 택배 마스터 광우 (0) | 2024.06.24 |
| 단어 변환 (0) | 2023.10.25 |
| 네트워크 (0) | 2023.10.24 |