public void dfs(int begin, ArrayList<Integer> nums) {
        if (begin >= nums.size()) {
            res.add(new ArrayList<Integer>(nums));
            return;
        }
        for (int i = begin; i < nums.size(); ++i) {
            swap(nums, i, begin);
            dfs(begin + 1, nums);
            swap(nums, i, begin);
        }
    }