본문 바로가기
Algorithm/Programmers

[Programmers] Lv.0 / 두 수의 연산값 비교하기 / Java

by unknownomad 2023. 10. 17.

문제

 

풀이

class Solution {
    public int solution(int a, int b) {
        int answer = 0;
        
        int first = Integer.parseInt("" + a + b);
        int second = 2 * a * b;
        
        if(first >= second) {
            answer = first;
        } else {
            answer = second;
        }
        return answer;
    }
}
class Solution {
    public int solution(int a, int b) {
        int first = Integer.parseInt(String.valueOf(a)+String.valueOf(b));
        int second = 2 * a * b;
        return Math.max(first, second);
    }
}

 

출처

https://school.programmers.co.kr/learn/courses/30/lessons/181938

댓글