Friday, December 23, 2022
A function to find the first non-repeating character in it and return its index. If it does not exist, it returns -1
.
func firstUniqChar(s string) int {
for index, rune := range s {
frequency := strings.Count(s, string(rune))
if (frequency == 1) {
return index
}
}
return -1
}