Find a Symbolic Matrix Pattern
Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Capital One reported this one in October 2026, and the detail that trips people up is Example 2: X and Y can't both map to 5, so a submatrix with matching values still fails. It's a bijection check on every window, not a value match. The hinted pattern says breadth-first-search, but this is really a brute-force scan of submatrices with two hash maps. If you blank on the mapping logic during the OA, StealthCoder is the safety net that reads the problem and hands you a working solution while you stay calm.
The problem
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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a two-way mapping. For each top-left corner in row-major order, walk the pattern cells and keep symbol-to-integer and integer-to-symbol maps. If a symbol is already mapped to a different integer, reject. If an integer is already claimed by a different symbol, reject. Both maps are needed. Most people only build the first one and fail Example 2. Return the first corner that survives the full window, else [-1, -1]. Cost is roughly (R-p+1)(C-q+1) times p*q, which is fine at 200 by 200 when most windows exit early on a conflict. The pitfalls: forgetting to reset the maps per window, scanning in column-major order, and bounding the loops wrong when the pattern is as wide as the matrix. Don't bother with BFS. Nothing here is a graph. If the live OA freezes your brain, StealthCoder is the hedge that gives you the double-map loop on screen.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Find a Symbolic Matrix Pattern cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Capital One's OA.
Capital One reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find a Symbolic Matrix Pattern FAQ
How hard is the Capital One symbolic matrix pattern problem really?+
Easy to medium. There's no clever algorithm, just careful bookkeeping. The difficulty is remembering that the mapping must be one-to-one in both directions. If you code it cleanly with two hash maps, it's a 20-minute problem.
What's the trick to this problem?+
Keep two maps per window: symbol to integer and integer to symbol. Reject on any conflict in either direction. Example 2 exists to catch solutions that only check that the same symbol maps to the same number.
Is it really a BFS problem?+
No. The hint says breadth-first-search, but nothing here traverses a graph. You iterate over every possible top-left corner and verify the window directly. Brute-force window checking with hash maps is the intended approach under these constraints.
Will brute force time out on a 200 by 200 matrix?+
Usually not. Worst case is about the number of windows times the pattern area, but most windows fail early on the first conflict, so you break out fast. Make sure you exit the moment a mapping breaks rather than finishing the window.
How do I prepare for this in 48 hours?+
Write the window-check function once from scratch. Test Example 2, a pattern with all distinct symbols, and a pattern with all identical symbols. Confirm you scan in row-major order and return [-1,-1] when nothing matches. That covers nearly every edge case.