ㅁ 내 풀이
class Solution {
public int solution(int a, int b) {
String first1 = String.valueOf(a) + String.valueOf(b);
int first2 = Integer.parseInt(first1);
int second = 2 * a * b;
if(first2 == second){
return first2;
}else{
return Math.max(first2, second);
}
}
}
ㅁ 다른 풀이
class Solution {
public int solution(int a, int b) {
int ab = Integer.parseInt(Integer.toString(a) + Integer.toString(b));
int ab2 = 2 * a * b;
return ab == ab2 ? ab : Math.max(ab, ab2);
}
}
'코딩테스트 > 프로그래머스 Lv.0' 카테고리의 다른 글
[코테/0레벨] 더 크게 합치기 (0) | 2025.02.23 |
---|---|
[코테/0레벨] 이어 붙인 수 (0) | 2025.02.23 |
[코테/0레벨] 0 떼기 (0) | 2025.02.11 |
[코테/0레벨] A 강조하기 (0) | 2025.02.11 |
[코테/0레벨] 특정한 문자를 대문자로 바꾸기 (0) | 2025.02.11 |