DEV Community

Cover image for Challenge: So Many Permutations!
Sandy Nguyen
Sandy Nguyen

Posted on

Challenge: So Many Permutations!

In this challenge, your task is to create all permutations of a non-empty input string and remove duplicates, if present.

Create as many "shufflings" as you can!

Examples:

With input 'a':
Your function should return: ['a']

With input 'ab':
Your function should return ['ab', 'ba']

With input 'abc':
Your function should return ['abc','acb','bac','bca','cab','cba']

With input 'aabb':
Your function should return ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa']
Enter fullscreen mode Exit fullscreen mode

Note: The order of the permutations doesn't matter.

Have fun!!

Top comments (0)