728x90
반응형
*문제 출처는 프로그래머스에 있습니다.

문제 제목: H-Index
문제 사이트: https://school.programmers.co.kr/learn/courses/30/lessons/42747#
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr

나의 풀이
def solution(citations):
answer = 0
h = 0
max_h = 0
max_ = max(citations)
if sum(citations) == 0:
return 0
while h < max_ + 1:
h_low = [citations[i] for i in range(len(citations)) if citations[i] <= h]
h_high = [citations[i] for i in range(len(citations)) if citations[i] >= h]
# h 편 이상, h편 이하의 값이 같아야함
if len(h_high) >= h and len(h_low) <= h :
max_h = max(h,max_h)
h += 1
return max_h

※ 알아야 할 것
- 문제만 잘 읽으면 할 수 있음
728x90
반응형
'coding test - python > Programmers' 카테고리의 다른 글
Programmers / [복습] 의상 - 해시 / Python 파이썬 (0) | 2025.04.03 |
---|---|
Programmers / [복습] 전화번호 목록 - 해시 / Python 파이썬 (0) | 2025.04.03 |
Programmers / 정수를 나선형으로 배치하기 - bfs, 달팽이 / Python 파이썬 (1) | 2025.04.01 |
Programmers / [복습] 할인 행사 - 슬라이딩윈도우 / Python 파이썬 (1) | 2025.03.30 |
Programmers / [복습] 피로도 - 순열 , 그리디 / Python 파이썬 (0) | 2025.03.30 |