
class Solution {
public int solution(int[][] dots) {
int answer = 0;
int w = 0;
int h = 0;
int x = dots[0][0];
int y = dots[0][1];
for (int i = 1; i < dots.length; i++) {
if (x != dots[i][0]) {
w = Math.abs(x - dots[i][0]);
}
if (y != dots[i][1]) {
h = Math.abs(y - dots[i][1]);
}
}
answer = w * h;
return answer;
}
}

class Solution {
public int[] solution(String[] keyinput, int[] board) {
int x = 0;
int y = 0;
int xLimit = (board[0] - 1) / 2; // x의 한계
int yLimit = (board[1] - 1) / 2; // y의 한계
for (String key : keyinput) {
switch (key) {
case "up":
if (y < yLimit) y++;
break;
case "down":
if (y > -yLimit) y--;
break;
case "left":
if (x > -xLimit) x--;
break;
case "right":
if (x < xLimit) x++;
break;
}
}
int[] answer = new int[]{x,y};
return answer;
}
}

class Solution {
public int solution(int[] numbers) {
int answer = Integer.MIN_VALUE;
for (int i = 0; i < numbers.length; i++) {
for (int j = i+1; j < numbers.length; j++) {
int product = numbers[i] * numbers[j];
if (product > answer) {
answer = product;
}
}
}
return answer;
}
}

class Solution {
public String solution(String polynomial) {
String answer = "";
String[] strArr = polynomial.split(" \\+ ");
int[] count = new int[2];
for(String str : strArr){
if(str.contains("x")){
str = str.replace("x", "");
count[0] += str.equals("") ? 1 : Integer.parseInt(str);
}else{
count[1] += Integer.parseInt(str);
}
}
if(count[0] > 0){
answer += count[0] == 1 ? "x" : count[0] + "x";
}
if(answer.length() > 0 && count[1] > 0){
answer += " + ";
}
if(count[1] > 0){
answer += count[1];
}
return answer;
}
}
이 문제는 풀지 못해서 풀이를 찾아봤다..