Skip to content

Instantly share code, notes, and snippets.

@sceeter89
Created September 23, 2015 18:43
Lin: Reorder array
import collections
input_array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
output_array = []
temp = collections.deque(input_array)
from_beginning = True
while temp:
output_array.append(temp.popleft() if from_beginning else temp.pop())
from_beginning = not from_beginning
print(output_array)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment