HARDasked at 3 companies

Count the Number of Infection Sequences

A hard-tier problem at 33% community acceptance, tagged with Array, Math, Combinatorics. Reported in interviews at Tekion and 2 others.

Founder's read

Count the Number of Infection Sequences is a hard combinatorics problem that's landed in OAs at Tekion, SAP, and Salesforce. The 33% acceptance rate tells you most candidates either miss the mathematical pattern or implement it wrong under interview pressure. You're given a grid or infection model, and you need to count how many distinct sequences lead to full contamination. It's not a brute-force simulation problem, even though it looks like one. The trick is recognizing that the order matters, the math is non-obvious, and if you haven't drilled this exact pattern, you'll run out of time.

Companies asking
3
Difficulty
HARD
Acceptance
33%

Companies that ask "Count the Number of Infection Sequences"

If this hits your live OA

Count the Number of Infection Sequences 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. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The core insight is that this problem requires combinatorics, not simulation. Candidates typically try to explore all possible infection orders using recursion or backtracking, which explodes exponentially and times out. The correct approach involves counting valid infection sequences using factorials and careful constraint tracking. You need to figure out which cells can be infected at each step, then multiply the number of valid choices at each stage. Common pitfall: confusing the order of infection with the shape of the infection. Another pitfall: not recognizing that certain cells create dependencies that reduce the total number of valid sequences. If you freeze on the live OA and can't reconstruct the combinatorial logic, StealthCoder will surface the working solution in seconds, invisible to the proctor.

Pattern tags

The honest play

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

Count the Number of Infection Sequences recycles across companies for a reason. It's hard-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. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count the Number of Infection Sequences interview FAQ

Is this problem actually asked at FAANG-adjacent companies?+

Yes. Tekion, SAP, and Salesforce have all included it in their online assessments. It's not a top-tier frequency problem, but if it lands in your OA, the 33% pass rate means most people don't get it. It's a high-value edge if you're prepared.

What's the trick I'm missing if I keep timing out?+

You're probably simulating all possible sequences instead of calculating them combinatorially. The answer involves factorials and constraint tracking, not recursive exploration of every infection path. Stop trying to explore. Start counting.

How does combinatorics apply here exactly?+

At each step of the infection, only certain cells can be infected next (those adjacent to already-infected cells). The number of valid sequences is the product of valid choices at each step. You're computing ordered arrangements under dependency constraints, not permutations of all cells.

If I haven't seen this exact pattern before, can I solve it live?+

Unlikely without recognizing the combinatorics angle first. The Array and Math topics hint that raw problem-solving won't cut it. If you blank on the approach, you'll time out trying brute force. That's where preparation or a safety net matters.

How much time should I budget for this in an OA?+

If you know the pattern, 20 to 30 minutes. If you don't, you'll spend an hour spinning on simulation and fail. The hard difficulty and low acceptance rate reflect a sharp on-off cliff: either you see it or you don't.

Want the actual problem statement? View "Count the Number of Infection Sequences" 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.