Skip to content

Commit

Permalink
H-index - leve2
Browse files Browse the repository at this point in the history
  • Loading branch information
sey2 authored Aug 24, 2022
1 parent b49e835 commit eb5d12e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions programmers/H-Index.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.Collections;
import java.util.Arrays;

class Solution {
public int solution(int[] citations) {
Integer[] tmp = Arrays.stream(citations).boxed().toArray(Integer[]::new);
Arrays.sort(tmp,Collections.reverseOrder());

int len = tmp.length;

for(int i=0; i<len; i++){
if(tmp[i] <= i) return i;
}

return len;
}
}

0 comments on commit eb5d12e

Please sign in to comment.