public void dfs(int[] A, ArrayList<Integer> path, HashSet<Integer> visited) {
        if (path.size() == A.length) {
            count += 1;
            if (compare(path)) {
                stop = true;
            }
            return;
        }
        for (int i = 0; i < A.length; ++i) {
            if (stop == true)
                return;
            int val = A[i];
            if (visited.contains(val))
                continue;
            visited.add(val);
            path.add(val);
            dfs(A, path, visited);
            visited.remove(val);
            path.remove(path.size() - 1);
        }
    }