A recursive approach (which is what I would use) would involve breaking the problem into isomorphic subproblems: to find all permutations of a string, find all permutations of the string without a ...
You are given a string s, which may contain duplicate characters. Your task is to generate and return an array of all unique permutations of the string. You can return the permutations in any order.
You are given a string s, which may contain duplicate characters. Your task is to generate and return an array of all unique permutations of the string. You can return the permutations in any order.
def perms(s, temp): """s is a string, temp is part of the output found so far.""" if len(s) == 0: print temp return for i in s: s2 = s.replace(i, '') temp += i perms ...
Some results have been hidden because they may be inaccessible to you
Show inaccessible results