3078. Match Alphanumerical Pattern in Matrix I
You are given a 2D integer matrix
boardand a 2D character matrixpattern. Where0 <= board[r][c] <= 9and each element ofpatternis either a digit or a lowercase English letter.Your task is to find a submatrix of
boardthat matchespattern.An integer matrix
partmatchespatternif we can replace cells containing letters inpatternwith some digits (each distinct letter with a unique digit) in such a way that the resulting matrix becomes identical to the integer matrixpart. In other words,
The matrices have identical dimensions.
If
pattern[r][c]is a digit, thenpart[r][c]must be the same digit.If
1 pattern[r][c]is a letter
1 x:
- For every
pattern[i][j] == x,part[i][j]must be the same aspart[r][c].- For every
pattern[i][j] != x,part[i][j]must be different thanpart[r][c].Return an array of length
2containing the row number and column number of the upper-left corner of a submatrix ofboardwhich matchespattern. If there is more than one such submatrix, return the coordinates of the submatrix with the lowest row index, and in case there is still a tie, return the coordinates of the submatrix with the lowest column index. If there are no suitable answers, return[-1, -1].
1 | class Solution { |