题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
import Foundation while let line = readLine() { var minCount = line.count + 1 var map = [Character:Int]() for ch in line { map[ch] = (map[ch] ?? 0) + 1 } for ch in map.keys { minCount = min(minCount, map[ch]!) } var str = "" for ch in line { if map[ch] != minCount { str.append(ch) } } print(str) // let parts = line.split(separator: " ") // print(Int(parts[0])! + Int(parts[1])!) }