Reported August 2024
TikTokbinary search

Min Days to Target Engagement

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 August OA asked you to calculate the minimum days to reach a target engagement metric. The problem feels like a business simulation but it's actually a binary search problem in disguise. You're given some engagement rate or cumulative growth rule, and you need to find the earliest day when you hit a threshold. The trap is overthinking the business logic instead of recognizing that you're searching for a boundary in a monotonic sequence. StealthCoder will catch this pattern instantly if you freeze on the first read.

Pattern and pitfall

The core pattern here is binary search on the answer. You can't just iterate day by day if the answer could be large; that times out. The trick is recognizing that engagement grows monotonically over time, so once you hit your target, you stay above it. Build a helper function that calculates engagement at any given day, then binary search for the smallest day where engagement meets or exceeds your target. Common mistake: brute force loop from day 1 upward. Another mistake: misunderstanding how engagement compounds (daily growth, cumulative, percentage-based). Read the problem text carefully for the exact rule. If you blank on the formula or the binary search bounds during the live OA, StealthCoder gives you the structure to fill in.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Min Days to Target Engagement 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Min Days to Target Engagement FAQ

Is this a math problem or a search problem?+

Both. You need to understand the engagement formula (the math), then binary search on the day range (the search). Don't get sucked into trying to solve it algebraically. Binary search is faster and cleaner.

How do I know the bounds for binary search?+

Left bound is 0 or 1. Right bound is something large like 10000 or 1e9, depending on the constraints. If the problem states a max timeline, use that. Otherwise, think about the worst case: how many days until even 1% daily growth hits 100x or 1000x?

What if the engagement rule is unclear in the problem?+

Re-read for examples or a sample input. Usually they give you the rule explicitly or show it via an example trace. If still unclear, ask for clarification before coding. Don't guess the formula.

Can I brute force from day 1 upward?+

Only if the answer is guaranteed small (under 1000). If the target is large or the engagement grows slowly, brute force will time out. Binary search is the safe bet.

What's the most common mistake on this problem?+

Forgetting to handle the boundary condition correctly: is the target inclusive or exclusive? Off-by-one errors in the binary search. And misreading whether engagement is per-day or cumulative total.

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