input: from typing import List
  
  def smallest_bounding_box_area(grid: List[List[int]]) -> int:
      """
      Given a 2D binary matrix grid, find the smallest rectangle (with sides parallel to the axes) that can encompass all 1's in the grid.
  
      Return the minimum area of such rectangle.
  
      Examples:
      >>> grid = [[0,1,0],[1,0,1]]
      6
      >>> grid = [[1,0],[0,0]]
      1
  
      Constraints:
      1 <= len(grid), len(grid[0]) <= 1000
      grid[i][j] is 0 or 1.
      There is guaranteed to be at least one 1 in grid.
      """
output:     
      rows = len(grid)
      cols = len(grid[0])
  
      min_row, max_row = rows, -1
      min_col, max_col = cols, -1
  
      for r in range(rows):
          for c in range(cols):
              if grid[r][c] == 1:
                  if r < min_row:
                      min_row = r
                  if r > max_row:
                      max_row = r
                  if c < min_col:
                      min_col = c
                  if c > max_col:
                      max_col = c
  
      width = max_col - min_col + 1
      height = max_row - min_row + 1
  
      return width * height
  