First non repeating character position in a string
// First non repeating character position in a string
package main
import (
"fmt";
"strings"
)
func FirstNonRepeating(str string) int {
strL := strings.ToLower(str)
for i:= range str {
count:=0
for j:= range str {
if strL[i] == strL[j] {
count++
}
}
if count == 1 {
return i
}
}
return -1
}
func main() {
fmt.Printf("First non repeating character position = %d",
FirstNonRepeating("abcdcba")) // 3
}