void backtrack(List<List<Integer>> result, ArrayList<Integer> list, int[] visited, int[] nums) {
        if (list.size() == nums.length) {
            result.add(new ArrayList<Integer>(list));
        } else {

            for (int i = 0; i < nums.length; i++) {
                if (visited[i] == 1 || (i != 0 && nums[i] == nums[i - 1] && visited[i - 1] == 0)) {
                    continue;
                }

                visited[i] = 1;
                list.add(nums[i]);
                backtrack(result, list, visited, nums);
                list.remove(list.size() - 1);
                visited[i] = 0;
            }

        }

    }