JOHNY: Getting wa

What’s wrong in my code at here https://www.codechef.com/viewplaintext/19778089

Two errors in your code-

  1. Why are you printing ans+1 while you’ve used 1 based indexing already.

  2. You are using 1 based indexing but your array is sorted from (0 to l+1)th index, since 0th element of array is not initialized, it contains garbage value, and after sorting its position will change which will cause wrong answer. Either initialize it to 0 or sort the array from 1 to l+1 index.