Help for Reversort engineering

I need some idea regarding question Reversort engineering. I am trying solving since last 12 hours. I have passed sample test cases but getting WA verdict regularly on test set1. Can anyone help what maybe the corner cases I am missing out. I have considered as much as test cases as I could.

Spoiler

Have you tried using the code for the first problem to test this one?

Create a random test case generator and checker (code for the first problem) to check if the array you output has actually cost C.

Only case where it would fail is when you print impossible for a valid C. For this you can write brute force. Create all permutations of size n to check if there exists a perm with cost c.

1 Like

Brother literally this helped me a lot. I was doing the same thing since morning but now realized where I was going wrong. Thanks again bro

1 Like