this time, these challanges gave me a hard time to solve it during the contest. Not because I was failing in logic or something but the language in both the question was absurd.

POSAND : I do not understand, for n ==1, answer is 1, as per the question , for N=1, the sequence {1} does not satisfy the condition for being a beautiful permutation.

it should be -1. because of uncleared statement I failed to submit in AC.

REPLESX : Assume there is case where duplicate exist and pth smallest comes out to be same as kth smallest. however, it shoud not be true if we have a element present which is greater than pth smallest but in this question they could be same. for example lets assume you have an array of [0 1 2 3 3 4 4 4 ] and p = 4, k = 5 Now 4th smallest and 5 th smallest in the array is same which is 3 but we have 4 available to assign it as 5th smallest (which is more logical).