์ƒˆ์†Œ์‹

IN DEPTH CAKE/Supercoder

[์ฝ”๋”ฉ/LeetCode150-(11)] 274. H-Index

  • -
๋ฐ˜์‘ํ˜•

 

๋ณธ ๊ธ€์€ LeetCode Top Interview 150์— ์ •๋ฆฌ๋œ ๋ฌธ์ œ๋ฅผ ์š”์•ฝํ•˜๊ณ  ์ด์— ๋Œ€ํ•œ ๊ฐœ์ธ์ ์ธ ํ’€์ด๋ฅผ ํฌํ•จํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค.
๋ณธ ํฌ์ŠคํŒ… ์‹œ๋ฆฌ์ฆˆ๋Š” 150 list์˜ ์ˆœ์„œ๋ฅผ ๋”ฐ๋ผ์„œ ๊ฒŒ์žฌ๋ฉ๋‹ˆ๋‹ค. ํ’€์ด ์–ธ์–ด๋Š” python3์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

 

 

๋‚œ์ด๋„Medium

ํ‚ค์›Œ๋“œ: Array, Sorting

 

๋ฌธ์ œ

 

๋ฌธ์ œ ์›๋ฌธ: https://leetcode.com/problems/h-index/description/?envType=study-plan-v2&envId=top-interview-150 

 

์ •์ˆ˜ ๋ฐฐ์—ด citations ์ด ์ฃผ์–ด์งˆ ๋•Œ H-index๋ฅผ ๋ฐ˜ํ™˜ํ•ด๋ผ

 

 

 

 

 

 

๋ฌธ์ œ ํ’€์ด

class Solution:
    def hIndex(self, citations: List[int]) -> int:

        citations.sort(reverse=True)
        for i in range(len(citations)):
            if citations[i] >= i+1:
                continue
            else: 
                return i
        return i + 1

 

 

๋ฐ˜์‘ํ˜•
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

# ๋กœ๋”ฉ ํ™”๋ฉด ๋™์ž‘ ์ฝ”๋“œ(Code) ์„ค์ •ํ•˜๊ธฐ