Why test case # 3 is showing wrong answer ?
R9--Found At Last
Hi @vaishnavtannu
See in your code you are sorting the array due to which index of elements gets changed and you print wrong index for that element.
For example :
7
86 -16 77 65 45 67 28
77
For this input case your code is printing 5 as answer, but the correct output should be 2.
This question can be solved using a simple recursive function.
Here is your corrected code :