huequad / swift-algorithm

1 stars 0 forks source link

64065. 튜플 #50

Open lenaios opened 3 years ago

lenaios commented 3 years ago

https://programmers.co.kr/learn/courses/30/lessons/64065

@ghis22130 둠바 다 풀었네~😊

zekexros commented 3 years ago

https://github.com/zeke-iOS/AlgorithmPractice/blob/main/Programmers/튜플.swift

ghis22130 commented 3 years ago
func solution(_ s:String) -> [Int] {
    return s.split { !$0.isNumber }
    .map { Int(String($0))! }
    .reduce(into: [Int:Int]()) { $0[$1] = $0[$1] != nil ? $0[$1]! + 1 : 1 }
    .sorted { $0.value > $1.value }
    .map { $0.0 }
}