I have a Hashmap called H1.
There are n Hashmap keys for H1.
For H1 hashmap, the program will create all the permutations of the powerset {1,2,3,4,...n}.
So in other words, if n = 5, any number from 1,2,3,..5555 is a valid list for H1.
So if,
Key 1 = 22
Key 2 = 50
Key 3 = 12
Key 4 = 44
Key 5 = 55
For 111 = {22,22,22}, for 213 = {50,22,12} for 12345 = {22,50, 12, 44, 55}.
I essentially need to find all of the lists in all possible combinations, in every order (i.e.: 1342 != 3142).
I have a possible solution, but I do not find it optimal at all, it involves converting int values to string and looking at each character element in the string, I am looking to see if anyone knows of a more efficient way.
Algorithm to generate all possible permutations of a list?
It's a complicated algorithm any way you want to do it, I think recursively is the fun way.
The recursive way basically removes one element, calls the recursion on the shortened list, then returns the recursive result with the removed element at each position.