
import java.util.*;
class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
HashMap<Integer, Integer> map = new HashMap<>();
map.put(6,1);
map.put(5,2);
map.put(4,3);
map.put(3,4);
map.put(2,5);
map.put(1,6);
map.put(0,6);
int[] answer = new int[2];
int correct = 0;
int zero = 0;
for(int i = 0 ; i < 6 ; i++){
if(lottos[i] == 0){
zero++;
continue;
}
for(int j = 0 ; j < 6 ; j++){
if(lottos[i] == win_nums[j]){
correct++;
break;
}
}
}
answer[0] = map.get(correct + zero);
answer[1] = map.get(correct);
return answer;
}
}
class Solution {
public int solution(String[] babbling) {
String[] canSay = {"aya","ye","woo","ma"};
int answer = 0;
for(String word : babbling){
boolean check = true;
for(String cur : canSay){
if(word.contains(cur + cur)){
check = false;
break;
}
word = word.replace(cur, " ");
}
if(check && word.trim().isEmpty()){
answer++;
}
}
return answer;
}
}
class Solution {
public String solution(String X, String Y) {
int[] countX = new int[10];
int[] countY = new int[10];
for(char c : X.toCharArray()){
countX[c - '0']++;
}
for(char c : Y.toCharArray()){
countY[c - '0']++;
}
StringBuilder sb = new StringBuilder();
for(int i = 9 ; i >= 0 ; i--){
int canPut = Math.min(countX[i], countY[i]);
sb.append(String.valueOf(i).repeat(canPut));
}
if(sb.length() == 0) return "-1";
if(sb.charAt(0) == '0') return "0";
return sb.toString();
}
}
import java.util.*;
class Solution {
public int solution(int n, int[] lost, int[] reserve) {
Arrays.sort(lost);
int lostP = lost.length;
int[] rS = new int[n + 2];
for(int cur : reserve){
rS[cur]++;
}
for(int i = 0 ; i < lost.length ; i++){
if(rS[lost[i]] > 0){
rS[lost[i]]--;
lost[i] = -1;
lostP--;
}
}
for(int i = 0 ; i < lost.length ; i++){
if(lost[i] == -1)continue;
if(rS[lost[i] - 1] > 0){
rS[lost[i] - 1]--;
lostP--;
}else if(rS[lost[i] + 1] > 0){
rS[lost[i] + 1]--;
lostP--;
}
}
return n - lostP;
}
}