[프로그래머스] 두 수의 연산값 비교하기

Seah Lee·2023년 6월 18일
0

프로그래머스

목록 보기
8/57

class Solution {
    public int solution(int a, int b) {
        
        String ab = ""+a+b;
        int ab1 = Integer.parseInt(ab);
        int ab2 = 2*a*b;
        
        if (ab1 >= ab2) return ab1;
        else return ab2;

    }
}

[다른 사람의 풀이]

class Solution {
    public int solution(int a, int b) {
        return Math.max(Integer.parseInt(String.valueOf(a)+String.valueOf(b)),2*a*b);
    }
}

Math.max(a,b) = a와 b 중 큰 수를 표시

profile
성장하는 개발자

0개의 댓글