더 크게 합치기

Psj·5일 전
0

내 풀이

class Solution {
    public int solution(int a, int b) {
        int answer = 0;
        String str1 = String.valueOf(a)+String.valueOf(b);
        String str2 = String.valueOf(b)+String.valueOf(a);

        if(Integer.valueOf(str1) > Integer.valueOf(str2)){
            answer = Integer.valueOf(str1);
        } else if(Integer.valueOf(str1) < Integer.valueOf(str2)){
            answer = Integer.valueOf(str2);
        } else{
            answer = Integer.valueOf(str1);
        }

        return answer;
    }
}

다른 사람 풀이

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;
    }
}
profile
Software Developer

0개의 댓글