Unable to understand my own code

Actually i successfully submitted the code of this problem but now i forgot the logic of my code. I have seen prateek bhaiya logic but it doesn’t match with my code. So can anyone help me understand my own logic. I know its hard but pls help me out.
https://ide.codingblocks.com/s/71135

Hi Divyam, this is a question on Binary Search application. Just see that on what parameter have you applied Binary Search and how have you compared the mid with ans, hi and lo,
and then the you will understand it.

Hope this helps :slight_smile:. If you still face a problem I will tell you directly then.

I know that but i don’t know how i build this code…i am unable to understand it. If u understand anything then pls tell me

Divyam in this

  1. u have sorted the array
  2. now u the checking two max value of
    1 to mid , mid+1 to end

so the bunary search u applied is to find that valye which is z using binary search
1 to mid ==x
mid+1 to n==y
then u are comparing it