The following code for above requirement. However I am not getting proper output. There is problem with input list that I am passing in recursion
import java.util.ArrayList;
import java.util.Collections;
public class abc
{
public static void m(ArrayList<Integer> op, ArrayList<Integer> ip) {
if(ip.size()==0) {
System.out.println(op);
return;
}
ArrayList<Integer> l1=new ArrayList<Integer>();
ArrayList<Integer> l2=new ArrayList<Integer>();
l1.addAll(op);
l2.addAll(op);
l1.add(ip.get(0));
ip.remove(0);
m(l2,ip);
m(l1,ip);
}
public static void main(String[] args) {
Integer [] z = {1,3,2};
ArrayList<Integer> ip=new ArrayList<Integer>();
Collections.addAll(ip, z);
ArrayList<Integer> op=new ArrayList<Integer>();
m(op,ip);
}
}