One solution can be the use of go map[]
to track the taken characters.
sample code:
func main() {
s := "abcdaabcefgahccij"
newS := ""
taken := make(map[rune]int)
for _, value := range s {
if _, ok := taken[value]; !ok {
taken[value] = 1
newS += string(value)
}
}
fmt.Println(newS)
}
Output:
abcdefghij
solved How to check words with the same characters where the words in one variable [closed]