Reported October 2024
IBMbacktracking

Count Teams

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

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

IBM's October assessment included Count Teams, a problem that catches candidates off guard because it looks like a simple counting exercise but requires careful handling of constraints and state. You've likely seen variants before, but the twist here is in how you track which soldiers or elements have already been used. StealthCoder will read the problem on screen during your live OA and surface the pattern instantly if you blank on the approach, giving you time to code cleanly instead of debugging under pressure.

Pattern and pitfall

Count Teams is fundamentally a combination or permutation problem wrapped in a domain-specific story. The core trick is understanding that you're selecting subsets of elements that satisfy specific constraints, usually relationships between indices or values. Most candidates either brute-force all subsets without pruning, or miss that elements can't be reused once placed in a team. The pattern involves either nested loops with careful bookkeeping, or recognizing that this is a backtracking or dynamic programming candidate depending on constraint size. If you're seeing N up to 100, backtracking with memoization or a clean DP state usually wins. StealthCoder handles the boilerplate and state transitions so you stay ahead of the clock.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Count Teams 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 would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

IBM reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Teams FAQ

Is this a backtracking problem or DP?+

Backtracking is your safest bet if N is small (under 20). You enumerate teams by choosing elements in order, prune invalid branches early, and count valid endpoints. If N is moderate (20-100), memoize the state: which elements are used and how many are in the current team. The recurrence is simple once you see it.

What's the most common mistake on Count Teams?+

Forgetting that soldiers or elements can't be reused once they're on a team, or miscounting duplicate team configurations as different teams. Also, many candidates don't clarify whether team order matters. Read the problem text carefully: if teams are unordered, you must avoid counting (A, B, C) and (B, A, C) twice.

How tight is the time limit?+

IBM's OAs typically give 60-90 minutes for the full session. Count Teams alone usually expects a clean solution in 20-30 minutes. If you're stuck after 15 minutes, outline your backtracking approach on paper, code the structure, then handle edge cases. Don't rewrite from scratch.

What if I can't figure out the exact constraints?+

Assume teams must satisfy some ordering or value-based property between members. Code a general backtracking skeleton first: choose element, recurse, un-choose. Then add constraint checks inside the recursion. Test against the examples to reverse-engineer the rule if it's ambiguous.

Should I use a set or list to track used elements?+

Use a boolean array or set, not a list. Boolean array with indices is faster and cleaner for backtracking. Mark used[i] = true when you pick element i, then used[i] = false when you backtrack. Avoid list membership checks in the hot loop.

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

OA at IBM?
Invisible during screen share
Get it