public void recur(List<List<Integer>> result, List<Integer> temp,
                      int[] candidates, int[] visited) {
        if (temp.size() >= candidates.length) {
            result.add(new ArrayList<Integer>(temp));
            return;
        }

        for (int i = 0; i < candidates.length; ++i) {
            if (visited[i] == 0) {
                visited[i] = 1;
                temp.add(candidates[i]);
                recur(result, temp, candidates, visited);
                temp.remove(temp.size() - 1);
                visited[i] = 0;

            }
        }
    }