SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
1-1000까지의 배열을 만들어서 입력 받은 숫자의 번호의 배열을 ++시켜줍니다.
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
int [] map=new int[10001];
int n=sc.nextInt();
int max=0;
for(int i=0;i<1000;i++){
int index=sc.nextInt();
map[index]++;
}
int x=0;
for(int i=0;i<1000;i++){
if(max<=map[i]){
max=map[i];
x=i;
}
}
System.out.println("#"+test_case+" "+x);
}
}
}
'알고리즘 > 삼성 SW expert Academy' 카테고리의 다른 글
[SWEA] 12741. 두 전구_JAVA (0) | 2022.05.17 |
---|---|
[SWEA] 13229. 일요일_JAVA (0) | 2022.05.17 |
[SWEA] 1288. 새로운 불면증 치료법_JAVA (0) | 2022.05.11 |
[SWEA] 1954. 달팽이 숫자_JAVA (0) | 2022.05.09 |
[SWEA] 1961. 숫자 배열 회전_JAVA (0) | 2022.05.07 |