thiagowfx's avatar

¬ just serendipity 🍀 (not just serendipity)

LeetCode #274: H-Index

• 31 words • 1 min • updated

LeetCode #274: H-Index:

python
class Solution:
    def hIndex(self, citations: List[int]) -> int:
        citations.sort(reverse=True)

        h = 0

        while h < len(citations):
            if h < citations[h]:
                h += 1
            else:
                break

        return h