Hello @mridulpant, don’t worry your code is absolutely fine. I have reviewed it and also tried it in various cases.
The issue was that the format of the input in that input case is wrong that’s why it was giving the error.
9 8 7 6 5 4 3 2 1
The input must look like this all the array nos. must be in a single line.
But in the given input file the nos. were arranged like this,
Although your code is running fine on this test case as well.
I hope you understand this issue. And I will try to get it correct as soon as possible.