File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ # 더 크게 합치기  
2+ 
3+ ## 📌 문제 설명  
4+ 
5+ 연산 ⊕는 두 정수에 대한 연산으로 두 정수를 붙여서 쓴 값을 반환합니다. 예를 들면 다음과 같습니다.
6+ 
7+ -  12 ⊕ 3 = 123
8+ -  3 ⊕ 12 = 312
9+   
10+ 양의 정수 a와 b가 주어졌을 때, a ⊕ b와 b ⊕ a 중 더 큰 값을 return 하는 solution 함수를 완성해 주세요.
11+ 
12+ 단, a ⊕ b와 b ⊕ a가 같다면 a ⊕ b를 return 합니다.
13+ 
14+ ### 제한 조건  
15+ 
16+ -  1 ≤ a, b < 10,000
17+ 
18+ ### 입출력 예  
19+ 
20+ |  a  |  b  |  result | 
21+ |  -- |  -- |  ------ | 
22+ |  9  |  91 |  991    | 
23+ |  89 |  8  |  898    | 
24+ 
25+ # 🧐 접근  
26+ 
27+ ` StringBuilder ` 사용
28+ 
29+ ``` java 
30+ class  Solution  {
31+     public  int  solution (int  a , int  b ) {
32+         StringBuilder  typeA =  new  StringBuilder (String . valueOf(a)). append(b);
33+         StringBuilder  typeB =  new  StringBuilder (String . valueOf(b)). append(a);
34+         
35+         return  Math . max(Integer . parseInt(typeA. toString()), Integer . parseInt(typeB. toString()));
36+     }
37+ }
38+ ``` 
39+ 
40+ # 💡 풀이  
41+ 
42+ ` StringBuilder ` 를 사용해서 정수를 이어붙인 후, ` Math.max() ` 메소드를 사용하여 최댓값을 반환한다.
43+ 아래와 같이 ` "" ` 를 사용해도 무관하다.
44+ 
45+ ``` java 
46+ class  Solution  {
47+     public  int  solution (int  a , int  b ) {
48+         return  Math . max(Integer . parseInt(" " +  a +  b), Integer . parseInt(" " +  b +  a));
49+     }
50+ }
51+ ``` 
52+ 
53+ # 📘 그 외의 풀이  
54+ 
55+ ### ==================  
Original file line number Diff line number Diff line change 6363-  [ 58. 문자열 곱하기] ( ./Lv0/multipleOfString.md ) 
6464-  [ 59. 홀짝 구분하기] ( ./Lv0/separateEvenOdd.md ) 
6565-  [ 60. 이어 붙인 수] ( ./Lv0/concatNum.md ) 
66+ -  [ 61. 더 크게 합치기] ( ./Lv0/sumMax.md ) 
6667
6768# 📘 Lv.1  
6869
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments