I am working on a problem where I have to obtain all permutations of an arraylist of numbers. The only restriction is that any number can't start with 0, so if we have [0,1,2] we would obtain
[1,2,0]
[1,0,2]
[2,0,1]
[2,1,0]
I know how to do this with 3 loops but the thing is that I have to repeat this to different sets of numbers with different sizes, so I need one method that I can apply to different sets of numbers. Unfortunately, I have no clue how to do this. I imagine I have to use some kind of recursive function but I don't know how to implement it so the numbers cant start with a 0. Any ideas? Please help me understand the problem, don't just post working code.