from typing import List
from typing import Set


def get_valid_digits(grid: List[List[int]], i: int, j: int) -> Set[int]:
    """Finds all of the digits that could be placed in cell (i, j) of grid."""

    digits = set(range(1, 10))

    # remove digits in same row or column
    for k in range(9):
        row_digit = grid[i][k]
        if row_digit in digits:
            digits.remove(row_digit)

        col_digit = grid[k][j]
        if col_digit in digits:
            digits.remove(col_digit)

    # remove digits in same 3x3 box
    box_i = (i // 3) * 3
    box_j = (j // 3) * 3
    for row in range(box_i, box_i + 3):
        for col in range(box_j, box_j + 3):
            box_digit = grid[row][col]
            if box_digit in digits:
                digits.remove(box_digit)

    return digits