Pivot or peak element using binary search

code : https://ide.codingblocks.com/s/245705

ques : https://hack.codingblocks.com/app/practice/1/496/problem

what is wrong in the code?

This is the algorithm to solve this problem:

  • Find middle point mid = (l + h)/2
  • If key is present at middle point, return mid.
  • Else If arr[l…mid] is sorted
    a) If key to be searched lies in range from arr[l] to arr[mid], recur for arr[l…mid].
    b) Else recur for arr[mid+1…r]
  • Else (arr[mid+1…r] must be sorted) .
    a) If key to be searched lies in range from arr[mid+1] to arr[r], recur for arr[mid+1…r].
    b) Else recur for arr[l…mid]
    Follow these steps in sequence you will get to know what is wrong with your code

the code which i have written passes all test cases in leetcode and geeksforgeeks

why not here? can you please look