I am in need of an algorithm (preferably Java) that can find the combination of a sequence of numbers. Here is an example that I would like to achieve.
Suppose the given sequence of number is: 1 2 3
I am expecting the output to be:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
1 2
1 3
2 1
2 3
3 1
3 2
1
2
3
I remember I've searched this before here in stackover flow and I found the answer but that was like 2 years ago. Now I'm doing a project and I needed that algorithm again.