Go题库9_提取不重复的数
package main import ( "fmt" "strings" ) func main() { var ( b strings.Builder str string newStr string ) fmt.Scan(&str) for i := len(str); i > 0; i-- { res := strings.IndexAny(newStr, string(str[i-1])) if res < 0 { b.WriteByte(str[i-1]) newStr = b.String() } } fmt.Println(newStr) }