Skip to content

Commit 290444e

Browse files
committed
feat : 프로그래머스 정렬
1 parent 3ce274b commit 290444e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package sgyj.programmers.yeji.sort;
2+
3+
import java.util.Arrays;
4+
5+
public class Solution42747 {
6+
public static int solution(int[] citations) {
7+
int answer = 0;
8+
Arrays.sort( citations );
9+
for(int i=0;i<citations.length; i++){
10+
int compare = 1;
11+
for(int j= i+1; j<citations.length; j++){
12+
if(citations[j]>=citations[i]){
13+
compare+=1;
14+
}
15+
}
16+
if(compare>=citations[i]) answer = Math.max( answer, citations[i] );
17+
}
18+
19+
return answer;
20+
}
21+
22+
public static void main ( String[] args ) {
23+
int[] citations = {3, 0, 6, 1, 5};
24+
System.out.println(solution(citations));
25+
}
26+
}

0 commit comments

Comments
 (0)