class Solution {
public int solution(String ineq, String eq, int n, int m) {
int answer = 0;
return answer;
}
}
class Solution {
public int solution(String ineq, String eq, int n, int m) {
int answer = 0;
if (ineq.equals("<") && eq.equals("=")) {
if (n <= m) {
answer = 1;
}
} else if (ineq.equals("<") && eq.equals("!")) {
if (n < m) {
answer = 1;
}
} else if (ineq.equals(">") && eq.equals("=")) {
if (n >= m) {
answer = 1;
}
} else { // else if (ineq.equals(">") && eq.equals("!"))
if (n > m) {
answer = 1;
}
}
return answer;
}
}
조건
총 4가지 경우의 수가 만들어진다
class Solution {
public int solution(String ineq, String eq, int n, int m) {
boolean answer = false;
switch(eq) {
case "!":
switch(ineq) {
case "<":
answer = n < m;
break;
case ">":
answer = n > m;
break;
}
break;
case "=":
switch(ineq) {
case "<":
answer = n <= m;
break;
case ">":
answer = n >= m;
break;
}
break;
}
return answer? 1 : 0;
}
}