-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestCharacter.java
76 lines (69 loc) · 1.92 KB
/
TestCharacter.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.*;
class TestCharacter {
public String solution(String[] survey, int[] choices) {
String answer = "";
int[] scores = new int[]{0,3,2,1,0,1,2,3};
Map<Character,Integer> map = new HashMap<>();
for(int i=0;i<choices.length;i++){
String str= survey[i];
int score = scores[choices[i]];
char c =survey[i].charAt(0);
char c2=survey[i].charAt(1);
if(choices[i]<4){
if(!map.containsKey(c2)){
map.put(c2,0);
}
if(map.containsKey(c)){
map.put(c,map.get(c)+score);
continue;
}
map.put(c,score);
}
else if(choices[i]>4){
if(!map.containsKey(c)){
map.put(c,0);
}
if(map.containsKey(c2)){
map.put(c2,map.get(c2)+score);
continue;
}
map.put(c2,score);
}
else{
if(map.containsKey(c)){
continue;
}
map.put(c,0);
if(map.containsKey(c2)){
continue;
}
map.put(c2,0);
}
}
if(map.get('R')==null||map.get('R')>=map.get('T')){
answer+="R";
}
else{
answer+="T";
}
if(map.get('C')==null||map.get('C')>=map.get('F')){
answer+="C";
}
else{
answer+="F";
}
if(map.get('J')==null||map.get('J')>=map.get('M')){
answer+="J";
}
else{
answer+="M";
}
if(map.get('A')==null||map.get('A')>=map.get('N')){
answer+="A";
}
else{
answer+="N";
}
return answer;
}
}