MEDIUMasked at 5 companies

Minimum Operations to Write the Letter Y on a Grid

A medium-tier problem at 62% community acceptance, tagged with Array, Hash Table, Matrix. Reported in interviews at ZipRecruiter and 4 others.

Founder's read

You're given a grid and need to write the letter Y by changing cells to a specific color, minimizing the number of operations. It sounds like a graphics problem but it's really a counting and pattern-matching challenge. ZipRecruiter, Capital One, Visa, Zeta, and Uber have all asked this. The trap is thinking you need a fancy algorithm when the win is recognizing which cells form the Y shape and then counting how many don't match your target color. Most candidates either misidentify the Y pattern or overthink the grid traversal. StealthCoder runs invisibly during your assessment and surfaces the exact cell indexing logic if you freeze on the geometry.

Companies asking
5
Difficulty
MEDIUM
Acceptance
62%

Companies that ask "Minimum Operations to Write the Letter Y on a Grid"

If this hits your live OA

Minimum Operations to Write the Letter Y on a Grid is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The Y letter on a grid has a specific geometric structure: two diagonal arms converging into a vertical stem. The trick is enumerating which cells belong to the Y without hardcoding coordinates. You'll use Array and Matrix traversal to locate the center and arms, then Hash Table or counting logic to track mismatches. The common pitfall is not handling the grid size correctly (odd vs. even dimensions) or miscounting the stem length. Once you lock down which cells form the Y, the solution collapses into a single pass: count cells in the Y region that don't already have the target color. This is where acceptance sits at 62 percent; candidates nail the geometry or the counting, rarely both. If you hit this live and blank on the Y coordinates, StealthCoder solves it in seconds without the proctor knowing.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Minimum Operations to Write the Letter Y on a Grid recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Operations to Write the Letter Y on a Grid interview FAQ

What's the actual trick to identifying the Y pattern on the grid?+

The Y has two symmetric diagonal arms from the top corners that meet at the center, then a vertical stem down the middle. You need to find the center row where the diagonals meet, then iterate outward for the arms and downward for the stem. Indexing is everything here; off-by-one errors kill your solution.

Why is this problem Medium and not Easy?+

The geometry is simple but the grid-indexing logic trips people up. You need to handle both the diagonal logic (checking opposite corners simultaneously) and the stem correctly. Hash Table or a set helps track which cells form the Y, then counting becomes trivial. The difficulty sits at the intersection of correct pattern recognition and clean implementation.

Is this still asked at these companies or is it an old problem?+

Five major companies including Uber and Visa have reported asking it, so it's still live in their interview loops. It's the kind of problem that tests your ability to translate geometry into code under pressure, which is valuable signal to them.

How does this relate to the Matrix and Counting topics?+

Matrix is the data structure you traverse; Counting is how you solve it. You iterate through the grid (Matrix), identify which cells belong to the Y (pattern recognition), and count how many don't match the target color. No sorting, no advanced data structures, just clean enumeration and a counter.

What's the most common mistake?+

Miscalculating which cells belong to the Y shape, especially the transition point where the two arms meet the stem. Candidates often hardcode offsets or forget to check symmetry. Build a helper function that returns True if a given (row, col) belongs to the Y, then iterate once and count. That separation of concerns prevents logic errors.

Want the actual problem statement? View "Minimum Operations to Write the Letter Y on a Grid" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.