Reported February 2026
ZipRecruiterhash table

Restaurant Vote Leaders

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

The ZipRecruiter OA reported in February 2026 hides its trap in the first line: ragged rows. Check that before you score anything, or your clean hash map answers the wrong question. It's a counting problem with a weighted twist. Tally points per restaurant, find the max, return the ties sorted. Simple on paper, but the empty and mismatched inputs are where people lose cases. If you blank on the order of checks, StealthCoder runs invisibly during the live OA as a safety net and hands you the solution. Here's the script.

The problem

You are given a two-dimensional array of restaurant names, rankings, and a boolean weighted.
Every row is one list of restaurant votes. If the rows do not all have the same length, return an empty array.
When weighted is false, every cell contributes 1 point to its restaurant.
When weighted is true and a row has m columns, the restaurant at index j receives m - j points. Each row therefore assigns weights m, m - 1,..., 1.
Return every restaurant whose total score is maximal, in ascending lexicographic order.
Every cell contributes independently, including repeated appearances of the same restaurant within one row. If rankings is empty or its rows contain no names, return an empty array.

Function
restaurantVoteLeaders(rankings: String[][], weighted: boolean) → String[]

Examples
Example 1
rankings = [["a","b","c"],["a","c","d"]]
weighted = false
return = ["a","c"]
Restaurants a and c each appear twice. They share the maximum score, so both are returned in lexicographic order.
Example 2
rankings = [["a","b","c"],["a","c","d"]]
weighted = true
return = ["a"]
Each row assigns weights 3, 2, and 1. Restaurant a receives 6 points, more than any other restaurant.
Example 3
rankings = [["a","b"],["a"]]
weighted = false
return = []
The rows have different lengths, so the required result is an empty array.

Constraints
0 <= rankings.length <= 1000
Every restaurant name contains between 1 and 50 characters.
The total number of cells is at most 100000.
If rankings is rectangular, every row has the same number of columns.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is a hash map of name to score. First, validate: if rankings is empty, or the first row is empty, or any row length differs from the first, return an empty array. Do this before counting. Then loop every cell. Unweighted adds 1. Weighted adds m - j, where j is the zero-based column index and m is the row length. Repeated names in one row each count separately, so don't dedupe. Track the max, collect every name equal to it, then sort lexicographically. The common pitfall is returning early on the first max instead of collecting ties, or sorting by score instead of by name. Another is off-by-one on weights, which should run m down to 1. Complexity is O(N + K log K) for N cells and K distinct names. If you freeze mid-assessment, StealthCoder is the hedge that covers the validation order and tie handling.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Restaurant Vote Leaders 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 passed his OA cold and still thinks the filter is broken.

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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Restaurant Vote Leaders FAQ

How hard is Restaurant Vote Leaders really?+

Easy to medium. The algorithm is a single pass with a hash map. The difficulty is in the edge cases: ragged rows, empty input, empty rows, and ties. If you handle those first, the rest is a few lines of code.

What's the trick to this problem?+

Validate the shape before scoring. Return an empty array if rankings is empty, rows have no names, or row lengths differ. After that, accumulate scores in a map, find the max, and return all tied names sorted.

How are weighted points calculated?+

For a row with m columns, the restaurant at zero-based index j gets m - j points. So a three-column row gives 3, 2, 1. Each cell counts on its own, even if the same restaurant appears twice in a row.

Do I need to worry about duplicates in a row?+

Yes, but only to not remove them. Every cell contributes independently, so a name appearing twice in one row gets points twice. Don't use a set per row. Just add to the map for every cell.

How do I prepare for this in 48 hours?+

Write it once from scratch with a hash map and a final sort. Then test the three examples plus an empty list, a list of empty rows, and a ragged input. Practice returning all ties, not one winner.

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