Find a Symbolic Pattern in a Numeric Matrix
Updated
Problem statement
Slide pattern over every fitting position of matrix in row-major order. A pattern token is either an integer literal or one lowercase letter.
- An integer literal must equal the covered matrix value.
- Every occurrence of one letter must map to the same value.
- Different letters must map to different values.
Return the first matching top-left coordinate, or [-1,-1] when none exists.
Function
findSymbolicPattern(matrix: int[][], pattern: String[][]) → int[]Examples
Example 1
matrix = [[9,9,9,4,1],[9,9,9,1,8]]pattern = [["4","a"],["a","8"]]return = [0,3]The source-shaped pattern first matches at coordinate [0,3].
Example 2
matrix = [[1,2],[3,4]]pattern = [["9"]]return = [-1,-1]A missing literal returns the sentinel.
Constraints
1 <= matrix rows, columns <= 1001 <= pattern rows, columnsand the pattern fits inside the matrix.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Gaussian Naive Bayes Classifier (Machine Learning OA)Pinterest · OAPinterest interview questions
- Find a Symbolic Matrix PatternCapital One · OACapital One interview questions
- First Completed Mingo LineEpic · OAEpic interview questions
- Count 2x2 Submatrices by Black CellsTikTok · OATikTok interview questions
- Hidden ArtifactsIMC Trading · OAIMC Trading interview questions
- Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
- Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Sudoku Board ValidationConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
- Sparse Matrix MultiplicationByteDance · PHONE SCREENByteDance interview questions
- Set Matrix ZeroesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions