comefrom: <awangdev>Search a 2D Matrix_2.java
code: public boolean searchMatrix(ArrayList<ArrayList<Integer>> matrix, int target) {
          if(matrix.size() == 0) {
              return false;
          }
          int rows = matrix.size();
          int cols = matrix.get(0).size();
          int start = 0;
          int end = rows * cols - 1;
          int mid;
          
          while (start + 1 < end) {
              mid = start + (end - start) / 2;
              int midVal = matrix.get(mid / cols).get(mid % cols); 
              
              if (midVal == target) {
                  return true;
              } else if (midVal < target) {
                  start = mid;
              } else {
                  end = mid;
              }
          }
          
          int startVal = matrix.get(start / cols).get(start % cols); 
          int endVal = matrix.get(end / cols).get(end % cols); 
          if (startVal == target || endVal == target) {
              return true;
          } else {
              return false;
          }
      }
masked: public boolean var_0 ( ArrayList < ArrayList < Integer >> var_3 , int var_4 ) {
    if ( var_3 . size ( ) == 0 ) {
      return false ;
    }
    int var_7 = var_3 . size ( ) ;
    int var_9 = var_3 . get ( 0 ) . size ( ) ;
    int var_10 = 0 ;
    int var_12 = var_7 * var_9 - 1 ;
    int var_13 ;
    while ( var_10 + 1 < var_12 ) {
      var_13 = var_10 + ( var_12 - var_10 ) / 2 ;
      int var_15 = var_3 . get ( var_13 / var_9 ) . get ( var_13 % var_9 ) ;
      if ( var_15 == var_4 ) {
        return true ;
      }
      else if ( var_15 < var_4 ) {
        var_10 = var_13 ;
      }
      else {
        var_12 = var_13 ;
      }
    }
    int var_16 = var_3 . get ( var_10 / var_9 ) . get ( var_10 % var_9 ) ;
    int var_17 = var_3 . get ( var_12 / var_9 ) . get ( var_12 % var_9 ) ;
    if ( var_16 == var_4 || var_17 == var_4 ) {
      return true ;
    }
    else {
      return false ;
    }
  }
  