Solving Unlock problem


can anybody check what is the problem with this code

@dishask99,
Check your code against this test case:

Input:
5 1
3 4 1 2 5
Correct Output:
5 4 1 2 3