boolean find(int[] Y1, int[] Y2){
        visited[value(Y1)] = true;
        int n=Y1.length;
        boolean found=true;
        for(int i=0; i<n; i++){
            if(Y1[i]!=Y2[i]) found=false;
        }

        if(found) return true;
        for(int i=0; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                if(Y1[i]>Y1[j]){
                    int[] clone = Arrays.copyOf(Y1, n);
                    int tmp = clone[i];
                    clone[i]=clone[j];
                    clone[j]=tmp;
                    if(!visited[value(clone)]) found |= find(clone, Y2);
                }
            }
        }
        return found;
    }