Zig Zag Sequence

  • + 0 comments

    In java with Java 8 only there not problem Only 3 lines

    int mid = (n)/2;
            int temp = a[mid];
            a[mid] = a[n - 1];
            a[n - 1] = temp;
        
            int st = mid + 1;
            int ed = n - 2;
            while(st <= ed){
                temp = a[st];
                a[st] = a[ed];
                a[ed] = temp;
                st = st + 1;
                ed = ed - 1;
            }