-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_181916.java
More file actions
48 lines (42 loc) · 1.04 KB
/
_181916.java
File metadata and controls
48 lines (42 loc) · 1.04 KB
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
import java.util.*;
class Solution {
public int solution(int a, int b, int c, int d) {
PriorityQueue<Integer> nums = new PriorityQueue<>(Collections.reverseOrder());
nums.add(a);
nums.add(b);
nums.add(c);
nums.add(d);
a = nums.poll();
b = nums.poll();
c = nums.poll();
d = nums.poll();
// 4개 일치
if (a == d){
return a*1111;
}
// 3개 일치
else if (a == c){
return (int)Math.pow((10 * a + d), 2);
}
else if (b == d){
return (int)Math.pow((10 * b + a), 2);
}
// 2개 일치
else if (a == b){
if (c == d){
return (a + c) * (a - c);
}
else {
return c * d;
}
}
else if (b == c){
return a * d;
}
else if (c == d){
return a * b;
}
// 불일치
else return d;
}
}