Reported June 2026
Alpacacounting

Hungarian Lottery Winner Counts

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

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

Alpaca reported this one in June 2026, and the detail that matters is in the constraints: up to 10^7 tickets, each with exactly five distinct numbers from 1 to 90. That's a counting problem wearing a lottery costume. You tally how many tickets hit exactly two, three, four, and five drawn numbers, then return the four counts in order. If you've got an OA invite for Alpaca, expect to write this in a few minutes. The hard part is staying clean on edge cases and not wasting time. StealthCoder is the safety net if your mind goes blank mid-assessment.

The problem

Players submit lottery tickets containing five distinct numbers. Given all submitted tickets and the five drawn numbers, count how many tickets match exactly two, three, four, and five drawn numbers.
Return the four counts in that order: [matches2, matches3, matches4, matches5].

Function
countLotteryMatches(tickets: int[][], drawn: int[]) → int[]

Examples
Example 1
tickets = [[1,2,3,4,5],[1,2,6,7,8],[1,2,3,9,10],[11,12,13,14,15]]
drawn = [1,2,3,4,5]
return = [1,1,0,1]
The four tickets match exactly five, two, three, and zero drawn numbers.
Example 2
tickets = [[1,2,3,4,5],[5,4,3,2,1]]
drawn = [1,2,3,4,5]
return = [0,0,0,2]
Ticket order does not matter; both tickets match all five numbers.
Example 3
tickets = []
drawn = [1,2,3,4,5]
return = [0,0,0,0]
No submitted tickets means no winners in any prize tier.

Constraints
0 ≤ tickets.length ≤ 10^7.
Every ticket and drawn contain five distinct integers from 1 through 90.
The input fits in memory.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to stop thinking about it as a lottery. Put the drawn numbers into a set, or a boolean array of size 91 for O(1) lookups. For each ticket, count how many of its five numbers are marked. That's five checks per ticket, so the total is O(5n), effectively linear. Keep an array of size 6 for the counts by match number, then return indices 2 through 5. The common pitfall is returning matches of 0 and 1 by mistake, or counting

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Hungarian Lottery Winner Counts 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Alpaca reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Hungarian Lottery Winner Counts FAQ

What's the trick to Hungarian Lottery Winner Counts?+

Mark the drawn numbers in a boolean array of size 91, then scan each ticket and count hits. Increment a counter array indexed by match count. Return indices 2, 3, 4, 5. No sorting and no nested comparison of tickets against each other is needed.

How hard is this Alpaca OA question really?+

Easy. It's a single pass with a lookup table. The only real risk is rushing and returning the wrong index order or including zero and one matches. Read the output order once, write the counts, and test the three examples.

Will 10^7 tickets cause a time limit problem?+

Not if you stay linear. Five lookups per ticket across 10^7 tickets is about 5x10^7 simple operations. Avoid building sets per ticket or sorting each ticket. A direct array lookup on the drawn numbers keeps it tight.

What edge cases should I test?+

Test the empty tickets list, which must return [0,0,0,0]. Test tickets with the same numbers in a different order, since order doesn't matter. Test tickets with zero or one match, which must not be counted anywhere in the output.

How do I prepare for this in 48 hours?+

Write it once from scratch in your language of choice. Practice the pattern of building a lookup structure, then scanning input and bucketing counts. That covers this problem and most similar counting questions. Then run the three examples by hand before you submit.

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

OA at Alpaca?
Invisible during screen share
Get it