<awangdev>Find Peak Element II_2.java
private List<Integer> find(int x1, int x2, int y1, int y2, int[][] A) {

        int midX = x1 + ((x2 - x1) >> 1); 
        int midY = y1 + ((y2 - y1) >> 1);

        int x = midX, y = midY; 
        int max = A[x][y];
        for (int j = y1; j <= y2; j++) {
            if (A[midX][j] > max) {
                max = A[midX][j];
                x = midX;
                y = j;
            }
        }

        for (int i = x1; i <= x2; i++) {
            if (A[i][midY] > max) {
                max = A[i][midY];
                y = midY;
                x = i;
            }
        }
 
        boolean isPeak = true;
        if (A[x - 1][y] > A[x][y]) {
            isPeak = false;
            x -= 1;
        } else if (A[x + 1][y] > A[x][y]) {
            isPeak = false;
            x += 1;
        } else if (A[x][y - 1] > A[x][y]) {
            isPeak = false;
            y -= 1;
        } else if (A[x][y + 1] > A[x][y]) {
            isPeak = false;
            y += 1;
        }

        if (isPeak) {
            return new ArrayList<Integer>(Arrays.asList(x, y));
        }

        if (x >= x1 && x < midX && y >= y1 && y < midY) {
            return find(x1, midX - 1, y1, midY - 1, A);
        }
        
        if (x >= x1 && x < midX && y > midY && y <= y2) {
            return find(x1, midX - 1, midY + 1, y2, A);
        }
        
        if (x > midX && x <= x2 && y >= y1 && y < midY) {
            return find(midX + 1, x2, y1, midY - 1, A);
        }
        
        if (x >= midX && x <= x2 && y > midY && y <= y2) {
            return find(midX + 1, x2, midY + 1, y2, A);
        }

        return new ArrayList<>();
    }
private List < Integer > sample_funcname ( int x1 , int x2 , int y1 , int y2 , int [ ] [ ] A ) {
  int midX = x1 + ( ( x2 - x1 ) >> 1 ) ;
  int midY = y1 + ( ( y2 - y1 ) >> 1 ) ;
  int x = midX , y = midY ;
  int max = A [ x ] [ y ] ;
  for ( int j = y1 ;
  j <= y2 ;
  j ++ ) {
    if ( A [ midX ] [ j ] > max ) {
      max = A [ midX ] [ j ] ;
      x = midX ;
      y = j ;
    }
  }
  for ( int i = x1 ;
  i <= x2 ;
  i ++ ) {
    if ( A [ i ] [ midY ] > max ) {
      max = A [ i ] [ midY ] ;
      y = midY ;
      x = i ;
    }
  }
  boolean isPeak = true ;
  if ( A [ x - 1 ] [ y ] > A [ x ] [ y ] ) {
    isPeak = false ;
    x -= 1 ;
  }
  else if ( A [ x + 1 ] [ y ] > A [ x ] [ y ] ) {
    isPeak = false ;
    x += 1 ;
  }
  else if ( A [ x ] [ y - 1 ] > A [ x ] [ y ] ) {
    isPeak = false ;
    y -= 1 ;
  }
  else if ( A [ x ] [ y + 1 ] > A [ x ] [ y ] ) {
    isPeak = false ;
    y += 1 ;
  }
  if ( isPeak ) {
    return new ArrayList < Integer > ( Arrays . asList ( x , y ) ) ;
  }
  if ( x >= x1 && x < midX && y >= y1 && y < midY ) {
    return find ( x1 , midX - 1 , y1 , midY - 1 , A ) ;
  }
  if ( x >= x1 && x < midX && y > midY && y <= y2 ) {
    return find ( x1 , midX - 1 , midY + 1 , y2 , A ) ;
  }
  if ( x > midX && x <= x2 && y >= y1 && y < midY ) {
    return find ( midX + 1 , x2 , y1 , midY - 1 , A ) ;
  }
  if ( x >= midX && x <= x2 && y > midY && y <= y2 ) {
    return find ( midX + 1 , x2 , midY + 1 , y2 , A ) ;
  }
  return new ArrayList < > ( ) ;
}
