private void helper(final int[] nums, final boolean[] used, final ArrayList<Integer> item, final ArrayList<ArrayList<Integer>> res) {
        if (nums.length == item.size()) {
            res.add(new ArrayList<Integer>(item));
            return;
        }

        for (int i = 0; i < nums.length; i++) {
            if (!used[i]) {
                used[i] = true;
                item.add(nums[i]);
                // have to always try this number in every location
                helper(nums, used, item, res);

                item.remove(item.size() - 1);
                // reset after recursion
                used[i] = false;
            }
        }
    }