
class Solution {
public boolean solution(boolean x1, boolean x2, boolean x3, boolean x4) {
boolean result = (x1 || x2) && (x3 || x4);
return result;
}
}

import java.util.*;
class Solution {
public int solution(int a, int b, int c, int d) {
int answer = 0;
Map<Integer, Integer> map = new HashMap<>();
// 각 숫자의 빈도를 계산하여 맵에 저장
map.put(a, map.getOrDefault(a, 0) + 1);
map.put(b, map.getOrDefault(b, 0) + 1);
map.put(c, map.getOrDefault(c, 0) + 1);
map.put(d, map.getOrDefault(d, 0) + 1);
// 모든 숫자가 동일한 경우
if (map.size() == 1) return a * 1111;
// 두 종류의 숫자로 이루어진 경우
if (map.size() == 2) {
if (map.containsValue(3)) {
// 한 숫자가 세 번, 다른 숫자가 한 번 나오는 경우
for (Map.Entry<Integer, Integer> el : map.entrySet())
answer += el.getKey() * (el.getValue() == 3 ? 10 : 1);
return answer * answer;
}
// 두 숫자가 각각 두 번 나오는 경우
int x = (a + b + c + d - 2 * a) / 2;
return (a + x) * Math.abs(a - x);
}
// 세 종류의 숫자로 이루어진 경우
if (map.size() == 3) {
answer = 1;
for (Map.Entry<Integer, Integer> el : map.entrySet())
if (el.getValue() != 2) answer *= el.getKey();
return answer;
}
// 네 숫자가 모두 다른 경우
return Math.min(Math.min(a, b), Math.min(c, d));
}
}
이 문제는 풀지 못했다. 내 머리로는 if문으로 조건을 쭉 나열하는것 밖에 안 나와서 풀다 포기했다.
Map에 저장하여 푸는 방법이 좋아보여 가지고왔고 다시 공부를 해봐야한다.

class Solution {
public String solution(String my_string, int[] index_list) {
StringBuilder answer = new StringBuilder();
for (int index : index_list) {
answer.append(my_string.charAt(index));
}
return answer.toString();
}
}

class Solution {
public int solution(String number) {
int answer = 0;
int plus = 0;
String[] split = number.split("");
for (int i = 0; i < split.length; i++) {
plus += Integer.parseInt(split[i]);
}
answer = plus % 9;
return answer;
}
}

import java.util.*;
class Solution {
public String solution(String my_string, int[][] queries) {
char[] arr = my_string.toCharArray();
for (int[] query : queries) {
int start = query[0];
int end = query[1];
while (start < end) {
char temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
}
}
return new String(arr);
}
}