Skip to content

Instantly share code, notes, and snippets.

@abdulrahmanAlotaibi
Created December 15, 2022 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdulrahmanAlotaibi/95abed6504b41330c15927a806cef390 to your computer and use it in GitHub Desktop.
Save abdulrahmanAlotaibi/95abed6504b41330c15927a806cef390 to your computer and use it in GitHub Desktop.
Strings : First Unique Character in a String
func firstUniqChar(s string) int {
for i:= 0 ; i < len(s) ; i++ {
ch := string(s[i])
isUnique := true
for j:= 0 ; j < len(s); j++ {
if j != i && string(s[j]) == ch {
isUnique = false
break
}
}
if isUnique {
return i
}
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment