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.
deffindZigZagSequence(a,n):a.sort()mid=int((n+1)/2)-1#1stEdit:added-1forthecorrectmida[mid],a[n-1]=a[n-1],a[mid]st=mid+1ed=n-2#2ndEdit:change-1to-2forthecorrectinitialedvaluewhile(st<=ed):a[st],a[ed]=a[ed],a[st]st=st+1ed=ed-1#3rdEdit:changed+1to-1forthecorrectswap.foriinrange(n):ifi==n-1:print(a[i])else:print(a[i],end=' ')returntest_cases=int(input())forcsinrange(test_cases):n=int(input())a=list(map(int,input().split()))findZigZagSequence(a,n)# Enter your code here. Read input from STDIN. Print output to STDOUT
`
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 →
output is correct, but fail all testcase???
`