Reported October 2022
ZipRecruitermatrix

Find a Symbolic Pattern in a Numeric Matrix

Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live ZipRecruiter OA. Under 2s to a working solution.
Founder's read

ZipRecruiter reported this one in October 2022, and the title sounds scarier than the problem. You slide a small pattern grid over a bigger numeric matrix and return the first top-left spot where it fits. Tokens are either integer literals or single lowercase letters, and letters act like variables. The hinted tag says breadth-first-search, but this is really a grid scan with a consistency check at each position. If you've got an OA invite, expect to write nested loops cleanly. StealthCoder is the safety net running invisibly during the live OA if your mind goes blank on the mapping logic.

The problem

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 <= 100
1 <= pattern rows, columns and the pattern fits inside the matrix.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Matrix is up to 100x100, so there are at most about 10,000 start positions. The pattern fits inside the matrix, so it's at most 100x100 too. Worst case is roughly 10^8 cell checks if you do it naively with no early exit, which is why you bail out on the first mismatch. Per position, keep two maps: letter to value, and value to letter. Literals must equal the covered cell. A letter seen before must map to the same value. A new letter can't claim a value already taken by a different letter. That reverse map is the classic pitfall, since people only check one direction. Scan in row-major order and return the first hit, else [-1,-1]. Don't reuse maps across positions. Reset them each time. If you freeze up in the live OA, StealthCoder gives you the loop skeleton and the two-map check so you can finish.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Find a Symbolic Pattern in a Numeric Matrix 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass ZipRecruiter's OA.

ZipRecruiter reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find a Symbolic Pattern in a Numeric Matrix FAQ

What's the actual trick in this ZipRecruiter problem?+

Bijective matching. Each letter must map to one value, and no two letters can share a value. Use a forward map and a reverse map per candidate position. Literals just compare directly. Everything else is plain nested loops over start positions.

Do I need BFS because it's tagged breadth-first-search?+

No. The tag is a loose hint. There's no graph traversal here. You iterate every top-left coordinate in row-major order and validate the pattern window. A straightforward brute-force scan with early exit fits the 100x100 constraints.

How do I handle a pattern token that is a number versus a letter?+

Tokens are strings. If the token is a lowercase letter, treat it as a variable. Otherwise parse it as an integer and compare it to the covered cell. Check the character with a simple letter test before parsing, so you don't crash on parse.

What are the edge cases to test before submitting?+

Test a pattern the same size as the matrix, a single-cell pattern like Example 2, and two different letters hitting the same value, which must fail. Also test the same letter hitting different values. Confirm you return [-1,-1] when nothing matches.

How should I prepare for this in 48 hours?+

Write the solution once from scratch. Focus on resetting the maps per position, breaking out early on mismatch, and returning coordinates as [row, col]. Run both examples by hand. That covers nearly everything this problem can throw at you.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with ZipRecruiter.

OA at ZipRecruiter?
Invisible during screen share
Get it