-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_77484.java
More file actions
34 lines (27 loc) · 982 Bytes
/
_77484.java
File metadata and controls
34 lines (27 loc) · 982 Bytes
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
import java.util.stream.*;
import java.util.*;
class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
int zeroCount = (int)Arrays.stream(lottos)
.filter(value -> value == 0)
.count();
int sameCount = Arrays.stream(lottos)
.reduce(0, (result, value) -> {
boolean found = Arrays.stream(win_nums)
.anyMatch(currentValue -> currentValue == value);
return result + (found ? 1 : 0);
});
int maxSameCount = sameCount + zeroCount;
int minSameCount = sameCount;
int maxScore = 7 - maxSameCount;
if (maxScore == 7) {
maxScore = 6;
}
int minScore = 7 - minSameCount;
if (minScore == 7) {
minScore = 6;
}
int[] answer = new int[] {maxScore, minScore};
return answer;
}
}