<gouthampradhan>binary_search_FindPeakElement_1.java
public int findPeakElement(int[] nums) {
    if (nums.length == 1) return 0;
    if (nums[0] > nums[1]) return 0;
    else if (nums[nums.length - 1] > nums[nums.length - 2]) return nums.length - 1;
    int l = 0, h = nums.length - 1;
    int ans = 0;
    while (l <= h) {
      int m = l + (h - l) / 2;
      if (m - 1 >= 0 && m + 1 < nums.length) {
        if (nums[m] > nums[m - 1] && nums[m] > nums[m + 1]) {
          return m;
        }
      }
      if (m - 1 >= 0 && nums[m - 1] > nums[m]) { 
        h = m - 1;
      } else {
        ans = l; 
        l = m + 1;
      }
    }
    return ans;
  }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 . length == 1 ) return 0 ;
  if ( var_0 [ 0 ] > var_0 [ 1 ] ) return 0 ;
  else if ( var_0 [ var_0 . length - 1 ] > var_0 [ var_0 . length - 2 ] ) return var_0 . length - 1 ;
  int var_5 = 0 , var_6 = var_0 . length - 1 ;
  int var_7 = 0 ;
  while ( var_5 <= var_6 ) {
    int var_8 = var_5 + ( var_6 - var_5 ) / 2 ;
    if ( var_8 - 1 >= 0 && var_8 + 1 < var_0 . length ) {
      if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] && var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) {
        return var_8 ;
      }
    }
    if ( var_8 - 1 >= 0 && var_0 [ var_8 - 1 ] > var_0 [ var_8 ] ) {
      var_6 = var_8 - 1 ;
    }
    else {
      var_7 = var_5 ;
      var_5 = var_8 + 1 ;
    }
  }
  return var_7 ;
}
