Skip to content

Commit 66f02e9

Browse files
committed
🟢 Solve problem 387
1 parent 1ee80b8 commit 66f02e9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎swift/387.swift‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
func firstUniqChar(_ s: String) -> Int {
3+
var dict: [Character : Int] = [:]
4+
5+
for character in s {
6+
dict[character, default: 0] += 1
7+
}
8+
9+
for (i, v) in s.enumerated() {
10+
if dict[v] == 1 {
11+
return i
12+
}
13+
}
14+
15+
return -1
16+
}
17+
}

0 commit comments

Comments
 (0)