@@ -0,0 +1,996 @@
+import java.util.*;%0Apublic class Solution %7B%0A    public List%3CList%3CInteger%3E%3E result = new ArrayList%3CList%3CInteger%3E%3E();%0A    public List%3CList%3CInteger%3E%3E permute(int%5B%5D num) %7B%0A        List%3CInteger%3E valuelist = new ArrayList%3CInteger%3E();%0A        this.dfs(num, valuelist);%0A        return this.result;%0A    %7D%0A%0A    public void dfs(int%5B%5D num, List%3CInteger%3E valuelist) %7B%0A        if (num.length == 0) %7B%0A            this.result.add(valuelist);%0A            return;%0A        %7D%0A        for (int i = 0; i %3C num.length; i++) %7B%0A            List%3CInteger%3E copy = new ArrayList%3CInteger%3E(valuelist);%0A            copy.add(num%5Bi%5D);%0A            int%5B%5D first_half = Arrays.copyOfRange(num, 0, i);%0A            int%5B%5D second_half = Arrays.copyOfRange(num, i+1, num.length);%0A            int%5B%5D newArray = new int%5Bnum.length-1%5D;%0A            System.arraycopy(first_half, 0, newArray, 0, first_half.length);%0A            System.arraycopy(second_half, 0, newArray, i, second_half.length);%0A            dfs(newArray, copy);%0A        %7D%0A    %7D%0A%7D%0A

Revert "rm permutation"