Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (16 sloc) 343 Bytes
class Solution:
def constructArray(self, n, k):
"""
:type n: int
:type k: int
:rtype: List[int]
"""
r = [i for i in range(1, n-k+1)]
s = r[-1]
d = 1
while len(r) < n:
s += d*k
r.append(s)
d = -d
k -= 1
return r