Reported September 2024
TikTokgreedy

Distribute Credits

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

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

TikTok's September OA included a distribution problem called Distribute Credits. You're looking at a resource allocation question that tests whether you can optimize the assignment of discrete units across entities, usually with constraints. The trick is figuring out if you're greedy, if you need to balance fairly, or if there's a math-based shortcut. This is the kind of problem where candidates either see it in 90 seconds or spin for 15 minutes. StealthCoder reads the exact constraints and feeds you the pattern so you don't blank on the live OA.

Pattern and pitfall

Distribution problems at TikTok typically hide under one of two patterns: greedy assignment or modular arithmetic. If the goal is to maximize total value or minimize waste, you'll likely iterate through entities in priority order and assign greedily. If the goal is fair allocation or you're given quotas, you'll do math upfront (total credits divided by count, remainders handled by rule). The common pitfall is overthinking order of operations. Candidates burn time writing nested loops when the answer is a formula or a single pass. Another trap: misreading whether order matters or if ties need special handling. In the live OA, if you blank on the exact approach, StealthCoder catches the detail you missed in the constraint section and points you toward greedy or math mode immediately.

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 Distribute Credits 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 TikTok's OA.

TikTok 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.

Distribute Credits FAQ

Is this a greedy problem or math?+

Usually both, but the split happens early. Read the goal: maximize total value (greedy, iterate and assign), or distribute fairly with minimal waste (math, divide-then-adjust). The constraint section tells you which. If you see 'minimize' or 'fair', think math first.

What's the trick TikTok puts in this problem?+

The trick is usually in the remainder handling or the priority rule. Candidates code a loop when they could compute total / count once, then handle leftovers by rule (round-robin, highest priority first, etc.). Read the tie-breaker or remainder rule carefully. That's where bugs hide.

Do I need to sort the input?+

Depends. If priority is explicit (e.g., 'entities with higher ID get first pick'), yes. If it's 'fair distribution', maybe not, but you might need to iterate in a specific order for ties. Read the problem. Don't assume.

How long should this take?+

A clean greedy or math-based solution takes 8-12 minutes once you see the pattern. If you're past 12 minutes, you're probably overthinking it. Step back and ask: is this just iteration plus math, or is there a hidden DP angle? Usually it's the former at TikTok.

What if I can't decide between two approaches?+

Code the simpler one first. Greedy with a single loop beats a recursive or DP solution that you'll debug. If your approach is O(n) or O(n log n) and produces a valid answer within limits, it's likely right. Submit and move on.

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

OA at TikTok?
Invisible during screen share
Get it