STUDYING/Algorithm
[Programmers] 가장 큰 수
EOZIN
2021. 9. 27. 00:40
728x90
https://programmers.co.kr/learn/courses/30/lessons/42746
import Foundation
func solution(_ numbers:[Int]) -> String {
let sortedNumbers: [Int] = numbers.sorted { Int("\($0)\($1)")! > Int("\($1)\($0)")! }
if sortedNumbers[0] == 0 {
return "0"
}
var numbersStr: [String] = sortedNumbers.compactMap{ String($0) }
let res = numbersStr.joined()
return res
}