Skip to content

Commit 59a5861

Browse files
authored
Create Solution.js
1 parent 4937851 commit 59a5861

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} citations
3+
* @return {number}
4+
*/
5+
var hIndex = function(citations) {
6+
citations.sort((a, b) => b - a);
7+
for (let h = citations.length; h; --h) {
8+
if (citations[h - 1] >= h) {
9+
return h;
10+
}
11+
}
12+
return 0;
13+
};

0 commit comments

Comments
 (0)