public   void leftRotate( int d) {
        int i, j, k, temp;
        int n = arr.length;
        int gcd = gcd(d, n);
        for (i = 0; i < gcd; i++) {
            /* move i-th values of blocks */
            temp = arr[i];
            j = i;
            while (true) {
                k = j + d;
                if (k >= n)
                    k = k%n;
                if (k == i)
                    break;
                arr[j] = arr[k];
                j = k;
                count++;
            }
            arr[j] = temp;
            count++;
        }
    }