208
社区成员




class Solution {
public void hanota(List<Integer> A, List<Integer> B, List<Integer> C) {
move(A, B, C, A.size());
}
public void move(List<Integer> a, List<Integer> b, List<Integer> c, int n) {
if(n == 1) {
c.add(a.get(a.size() - 1));
a.remove(a.size() - 1);
return;
}
move(a, c, b, n - 1);
c.add(a.get(a.size() - 1));
a.remove(a.size() - 1);
move(b, a, c, n -1);
}
}