We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
a.sort()
mid = int((n - 1)/2) ## from n + 1 to n - 1
a[mid], a[n-1] = a[n-1], a[mid]
st = mid + 1
ed = n - 2 ## from n - 1 to n - 2
while(st <= ed):
a[st], a[ed] = a[ed], a[st]
st = st + 1
ed = ed - 1 ## from ed + 1 to ed - 1
for i in range (n):
if i == n-1:
print(a[i])
else:
print(a[i], end = ' ')
return
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Zig Zag Sequence
You are viewing a single comment's thread. Return to all comments →
def findZigZagSequence(a, n):