-
프로그래머스 - 정수 내림차순으로 배치하기 [자바]Algorithms/- 프로그래머스 2022. 2. 3. 23:41
- 문제 링크 : 정수 내림차순으로 배치하기
정답
import java.util.*; class Solution { public long solution(long n) { char[] arr = String.valueOf(n).toCharArray(); Arrays.sort(arr); return Long.valueOf(new StringBuilder(new String(arr)).reverse().toString()); } }
분석
- sort하여 역순으로 돌리는 문제
반응형