Company: Capital One Oncampus_11june
Difficulty: medium
Find Matching Submatrix You are given a rectangular matrix of integers board and a square matrix of characters pattern . Every element of board is a digit (an integer from 0 to 9 ). Every character of pattern is either a digit or a lowercase English letter. Find a submatrix of board that matches pattern . A submatrix of board matches pattern when all of the following hold: The submatrix and pattern have identical dimensions. Wherever pattern holds a digit, the board value in the same position equals that digit. Wherever pattern holds a letter, every occurrence of that letter corresponds to the same board digit. Two distinct letters of pattern correspond to different board digits. A letter and a digit character carry no constraint between them: a letter is free to stand for a digit that also appears literally elsewhere in pattern . If at least one submatrix matches, report the row and column of the upper-left corner of the matching submatrix (0-indexed) with the smallest row index; if s