Zig Zag Sequence

  • + 0 comments

    In Python, I'm getting the same as the expected output but the tests fail.

    `def findZigZagSequence(a, n): a.sort() mid = (n - 1)//2 a[mid], a[n-1] = a[n-1], a[mid]

    st = mid + 1
    ed = n - 2
    while (st <= ed):
        a[st], a[ed] = a[ed], a[st]
        st += 1
        ed -= 1
    
    for i in range(n):
        if i == n-1:
            print(a[i])
        else:
            print(a[i], end=' ')
    return