▶문제설명
[SWEA] 1204. 최빈수 구하기
https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV13zo1KAAACFAYh&categoryId=AV13zo1KAAACFAYh&categoryType=CODE
▶Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import java.util.Scanner; import java.io.FileInputStream; import java.util.*; class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); int order = 0; while(0 < T) { int[] check = new int[101]; int answer = 0; order = sc.nextInt(); for(int i =0 ; i<1000 ; i++){ int idx = sc.nextInt(); check[idx]++; } int max = -1; for(int i = 0 ; i<=100 ; i++){ if(max <= check[i]){ max = check[i]; answer = i; } } System.out.printf("#%d %d\n",order, answer); T--; } } } | cs |
'■ 알고리즘 문제 풀이 > SWEA' 카테고리의 다른 글
[SWEA-D4] 1211. Ladder2 (0) | 2019.02.20 |
---|---|
[SWEA-D4] 1210. Ladder1 (0) | 2019.02.20 |
[SWEA-D3] 1209. Sum (0) | 2019.02.20 |
[SWEA-D3] 1206. View (0) | 2019.02.20 |
[SWEA-D3] 1208. Flatten (0) | 2019.02.20 |