字符串的全排列,通过0%,求解func permutation(s string) []string {// write code herestr := []byte(s)n := len(str)used := make([]bool, n)ans := make([]string, 0)help := make(map[string]bool)var dfs func(str []byte, path []byte)dfs = func(str []byte, path []byte) {if len(path) == n {tmp := make([]byte, len(path))copy(tmp, path)if _, ok := help[string(tmp)]; ok {return}ans = append(ans, string(tmp))help[string(tmp)] = truereturn}for i := 0; i < n; i++ {if !used[i] {path = append(path, str[i])used[i] = truedfs(str, path)used[i] = falsepath = path[:len(path)-1]}}}path := []byte{}dfs(str, path)return ans}