You are viewing a single comment's thread. Return to all comments →
I implemented without any condition but it still works
def absolutePermutation(n, k): res = list() for i in range(1,n+1): if 1<=i+k<=n: res.append(i+k) if k!=0 and i%k==0: k*=-1 if len(res)!=n: return [-1] return res
Seems like cookies are disabled on this browser, please enable them to open this website
Absolute Permutation
You are viewing a single comment's thread. Return to all comments →
I implemented without any condition but it still works