What's wrong with the Tower of Hanoi
import java.util.ArrayList; import java.util.List; public class Solution { public void move(int size, List<Integer>A, List<Integer>B, List<Integer>C){ if (size == 1){ C.add(A.get(0)); A.remove(0); } else { move(size-1,A,C,B); C.add(A.get(0)); A.remove(0); move(size-1,B,A,C); } } public static void main(String[] args){ List<Integer> a = new ArrayList<>(); List<Integer> b = new ArrayList<>(); List<Integer> c = new ArrayList<>(); a.add(3); a.add(2); a.add(1); a.add(0); Solution