```
public List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList();
if (nums == null || nums.length == 0)
return result;
helper(new ArrayList<Integer>(), result, nums);
return result;
}
private void helper(List<Integer> current, List<List<Integer>> result, int[] nums) {
if (current.size() == nums.length) {
result.add(new ArrayList(current));
}
for (int i = 0; i < nums.length; i++) {
if (!current.contains(nums[i])) {
current.add(nums[i]);
helper(current, result, nums);
current.remove(current.size() - 1);
}
}
}
```