내 답안
class Solution {
public int solution(int a, int b) {
int answer = 0;
int answer_a = 0;
int answer_b = 0;
String num_1 = Integer.toString(a) + Integer.toString(b);
String num_2 = Integer.toString(b) + Integer.toString(a);
answer_a = Integer.parseInt(num_1);
answer_b = Integer.parseInt(num_2);
if(answer_a > answer_b){
answer = answer_a;
}else{
answer = answer_b;
}
return answer;
}
}
Java
복사
다른 사람 풀이법
class Solution {
public int solution(int a, int b) {
int answer = 0;
int aLong = Integer.parseInt(""+a+b);
int bLong = Integer.parseInt(""+b+a);
answer = aLong > bLong ? aLong : bLong;
return answer;
}
}
Java
복사
class Solution {
public int solution(int a, int b) {
String strA = String.valueOf(a);
String strB = String.valueOf(b);
String strSum1 = strA + strB;
String strSum2 = strB + strA;
return Math.max(Integer.valueOf(strSum1), Integer.valueOf(strSum2));
}
}
Java
복사
class Solution {
public int solution(int a, int b) {
return Math.max(Integer.parseInt(a + "" + b), Integer.parseInt(b + "" + a));
}
}
Java
복사