mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-24 19:04:32 +08:00
15 lines
227 B
Go
15 lines
227 B
Go
package leetcode
|
|
|
|
func firstUniqChar(s string) int {
|
|
result := make([]int, 26)
|
|
for i := 0; i < len(s); i++ {
|
|
result[s[i]-'a']++
|
|
}
|
|
for i := 0; i < len(s); i++ {
|
|
if result[s[i]-'a'] == 1 {
|
|
return i
|
|
}
|
|
}
|
|
return -1
|
|
}
|