From 91977b618061a4f383f4d17a92dfccbdd4e76f08 Mon Sep 17 00:00:00 2001 From: Anusha Prabhu Date: Tue, 6 Oct 2020 21:57:54 +0530 Subject: [PATCH] Added H-Index --- LeetCode/0274_H_Index.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 LeetCode/0274_H_Index.py diff --git a/LeetCode/0274_H_Index.py b/LeetCode/0274_H_Index.py new file mode 100644 index 0000000..086042b --- /dev/null +++ b/LeetCode/0274_H_Index.py @@ -0,0 +1,11 @@ +class Solution: + def hIndex(self, citations: List[int]) -> int: + citations.sort() + n = len(citations) + if n==0: + return 0 + if set(citations) == {0}: + return 0 + for i in range(n): + if n-i<=citations[i]: + return n-i \ No newline at end of file