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.
if order for i - k to be at least 1 i needs be bigger then k. but if i = k you cant subtract k you need to add it and get k + k this must be <= n. in order for the permutation to be the mowest you should subtract k at the bery first chance. but the first k you need to add or go negative.
this leasts to a pattern of add then subtract that repeats with a period of 2k
Cookie support is required to access HackerRank
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 →
if order for i - k to be at least 1 i needs be bigger then k. but if i = k you cant subtract k you need to add it and get k + k this must be <= n. in order for the permutation to be the mowest you should subtract k at the bery first chance. but the first k you need to add or go negative. this leasts to a pattern of add then subtract that repeats with a period of 2k