Java Solution and recommended tutorial

public class Solution {
    ArrayList<ArrayList<Integer>> result = new ArrayList<>();
    public void findPermutations(ArrayList<Integer> soFar, ArrayList<Integer> rest)
        if(rest.size() == 0){
            result.add(new ArrayList<Integer>(soFar));
            for(int i=0; i<rest.size(); i++){
                int current = rest.remove(i);
                findPermutations(soFar, rest);
                rest.add(i, current);
    public ArrayList<ArrayList<Integer>> permute(ArrayList<Integer> A) {
        findPermutations(new ArrayList<Integer>(), A);
        return result;

Anyone who is finding difficult to understand how rescursion and backtracking works can see CS106B lectures 8-11 here