Code accpeted on leetcode, don't know why it fails here

In test cases it is not necessary that given elements form a permutation!
2
7
1 8 5 4 3 9 2
6
8 7 6 4 6 4
your code fails on above test!

It is written in the constraints that “A[i] is a permutation of [1, 2, …, A.length]”

More over, A[i] is not a permutation of 1, A.length() then what am i suppose to print.

you have to print the sequence for which flipping first k elements in given order sorts the array!

here answer is 6 2 3.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.