Python, Deque
Idea\nConsecutively use the smallest and largest available numbers from a deque of [1, 2, ... n] to form your unique pairs. You\'ll get a sequence n-1, n-2, n-3
# Idea\nConsecutively use the smallest and largest available numbers from a deque of [1, 2, ... n] to form your unique pairs. You\'ll get a sequence n-1, n-2, n-3, etc. Stop when you hit k-1. Then fill the rest with consecutive values which will all have a difference of 1. This will get you k unique values.\n\nP.S. you don\'t really need a deque, just need the left and right pointers.\n```\ndef constructArray(self, n: int, k: int) -> List[int]:\n\tdq = deque(range(1, n+1))\n\tres = []\n\tfor i in range(k):\n\t\tpop = dq.popleft if i & 1 else dq.pop\n\t\tres.append(pop())\n\tres.extend(reversed(dq) if k & 1 else dq)  # to make sure the diff stays 1\n\treturn res\n```
['Queue', 'Python', 'Python3']