Skip to content

Commit a6c34c3

Browse files
committed
[level 2] Title: H-Index, Time: 0.89 ms, Memory: 92.6 MB -BaekjoonHub
1 parent 57044ec commit a6c34c3

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed
Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1+
import java.util.*;
2+
13
class Solution {
24
public int solution(int[] citations) {
35
int answer = 0;
4-
int arr[] = new int[citations.length+1];
56

6-
for(int i : citations)
7-
{
8-
int cur =i;
9-
if(cur > citations.length)
10-
cur = citations.length;
11-
12-
arr[cur]++;
13-
}
14-
int sum =0;
15-
for(int i = arr.length-1; i>=1; i--)
16-
{
17-
sum += arr[i];
7+
Arrays.sort(citations);
8+
9+
for(int i =0; i<citations.length; i++) {
10+
int cur = citations[i];
1811

19-
if(sum >= i)
20-
{
21-
answer = i;
12+
if(citations.length- i <= cur) {
13+
answer= citations.length-i;
2214
break;
2315
}
24-
}
16+
}
2517
return answer;
2618
}
27-
}
19+
}
20+
21+
//0 1 3 5 6
22+
//1 2 5 6 7

프로그래머스/2/42747. H-Index/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 77.3 MB, 시간: 0.06 ms
7+
메모리: 92.6 MB, 시간: 0.89 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 07월 30일 10:04:44
19+
2025년 11월 10일 20:59:09
2020

2121
### 문제 설명
2222

0 commit comments

Comments
 (0)