Recca Chao 的 gitHub page

推廣網站開發,包含 Laravel 和 Kotlin 後端撰寫、自動化測試、讀書心得等。Taiwan Kotlin User Group 管理員。

View on GitHub

Hi, here's your problem today. This problem was recently asked by Amazon:

The h-index is a metric that attempts to measure the productivity and citation impact of the publication of a scholar. The definition of the h-index is if a scholar has at least h of their papers cited h times.

Given a list of publications of the number of citations a scholar has, find their h-index.

Example: Input: [3, 5, 0, 1, 3] Output: 3 Explanation: There are 3 publications with 3 or more citations, hence the h-index is 3.

Here's a starting point:

def hIndex(publications):
  # Fill this in.

print hIndex([5, 3, 3, 1, 0])
# 3