Find a Symbolic Matrix Pattern
Problem statement
Given an integer matrix matrix and a rectangular symbol grid pattern, find the first contiguous submatrix whose equality structure matches the pattern.
Each distinct symbol must map to exactly one integer. Repeated copies of a symbol must map to the same integer, and different symbols must map to different integers. Return the top-left coordinate [row, column] of the first match in row-major order, or [-1, -1] when no match exists.
Function
findSymbolicPattern(matrix: int[][], pattern: String[][]) → int[]Examples
Example 1
matrix = [[1,2,4,5],[2,3,6,7],[6,4,2,2]]pattern = [["A","T"],["T","B"]]return = [0,0]A maps to 1, T maps to 2, and B maps to 3.
Example 2
matrix = [[5,5],[5,6]]pattern = [["X","Y"],["Y","Z"]]return = [-1,-1]Different symbols X and Y cannot both map to 5.
Constraints
1 <= matrix.length, matrix[i].length <= 200.1 <= pattern.length <= matrix.length.- Every pattern row has the same positive length, no greater than the matrix width.
- Each symbol is a nonempty string of letters.