We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 507834f commit e291527Copy full SHA for e291527
GnuPark/programmers/완전탐색/모의고사.java
@@ -0,0 +1,47 @@
1
+import java.util.*;
2
+
3
+class Solution {
4
+ public static int[] solution(int[] answers) {
5
+ int[] answer;
6
7
+ int[] a = new int[] { 1, 2, 3, 4, 5 };
8
+ int[] b = new int[] { 2, 1, 2, 3, 2, 4, 2, 5 };
9
+ int[] c = new int[] { 3, 3, 1, 1, 2, 2, 4, 4, 5, 5 };
10
11
+ int[] score = new int[3];
12
13
+ // score[]에 수포자별 맞힌 갯수
14
+ for (int i = 0; i < answers.length; i++) {
15
+ if (answers[i] == a[i % 5])
16
+ score[0]++;
17
+ if (answers[i] == b[i % 8])
18
+ score[1]++;
19
+ if (answers[i] == c[i % 10])
20
+ score[2]++;
21
+ }
22
23
+ // 가장 높은 점수
24
+ int max = 0;
25
+ for (int i = 0; i < 3; i++) {
26
+ if (score[i] > max) {
27
+ max = score[i];
28
29
30
31
+ // 가장 높은 점수를 받은 사람 수
32
+ int maxCount = 0;
33
34
+ if (score[i] == max) {
35
+ maxCount++;
36
37
38
39
+ answer = new int[maxCount];
40
+ int idx = 0;
41
42
+ if (score[i] == max)
43
+ answer[idx++] = i + 1;
44
45
+ return answer;
46
47
+}
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments