Question: def perms(string): if len(string) == 0: return [''] prevList = perms(string[1:len(string)]) nextList = [] for i in range(0,len(prevList)): for j in range(0,len(string)): newString = prevList[i][0:j]+string[0]+prevList[i][j:len(string)-1]

def perms(string): if len(string) == 0: return [''] prevList = perms(string[1:len(string)]) nextList = [] for i in range(0,len(prevList)): for j in range(0,len(string)): newString = prevList[i][0:j]+string[0]+prevList[i][j:len(string)-1] if newString not in nextList: nextList.append(newString) return nextList

I want to fix this function so instead of returning a list of permutations it will return a set. the objective of the above function is to recursively reutrn Given a string s, return a set of all possible permutations of the letters in s.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!