import Foundation
func solution(_ s:String) -> String {
var targetDict:[String:Int] = [:]
var resArr:[String] = []
for i in s.map{String($0)} {
if targetDict.keys.contains(i) {
targetDict[i]! += 1
continue
}
targetDict[i] = 1
}
_ = targetDict.map{ curKey, curVal in
if curVal == 1 {
resArr.append(curKey)
}
}
return resArr.sorted(by: <).joined(separator: "")
}
'알고리즘' 카테고리의 다른 글
[Swift 알고리즘] 디스크 컨트롤러 (0) | 2023.05.15 |
---|---|
[Swift 알고리즘] 소수찾기(완전탐색) (0) | 2023.05.11 |
[Swift 알고리즘] 프로그래머스 옹알이 (2) (0) | 2023.05.02 |
[Swift 알고리즘] 백준 1377 버블소트 (0) | 2023.04.18 |
[Swift 알고리즘] 백준 2133 타일 채우기 (0) | 2023.04.14 |