题目:删除字符串中重复出现的字符,输入“FlyElephant”,返回“FlyEephant”.
核心代码:
<pre><code>`
func deleteDuplicationChar(origin:String) -> String {
var dict:[String:Int] = [:]
var result:String = ""
for i in 0..<origin.characters.count {
let char:String = origin[i]
if dict[char] == nil {
result += char
dict[char] = 1
}
}
return result
}`</code></pre>
测试代码:
<pre><code>`
var simple:String = hashSearch.deleteDuplicationChar(origin: "FlyElephant")
print("FlyElephant-去除重复之后的字符串---(simple)")`</code></pre>