int isprime(int x) { int flag = 1; for (int i = 2; i <= sqrt(x); i++) if (x%i==0) { flag = 0; break; } return flag; } And by now, we reduced the loop range from (x-1) to (x/2) to √x, and the reduction is MEGA
You have two arrays of the same length n, and you have to calculate minimum number of swaps of two arbitrary indexes which transform the first array A into the second B. ( All elements in arrays are not neccessery distinct ) I know how to solve this problem when all elements are distin...