Days Until a Creator's Follower Count Beats Today's Total
Last updated: November 29, 2026
Quick Overview
Given a creator's daily follower totals, return for each day how many days later the total is first strictly higher, or 0 if it never is.
TikTok
November 29, 20260
0
0 solved
Given a creator's daily follower totals, return for each day how many days later the total is first strictly higher, or 0 if it never is.
This shows up in TikTok phone screens as a framing of creator analytics, such as 'days to recover after a follower dip'. The interviewer is checking whether you go past the O(n^2) double loop to a monotonic stack and can explain the invariant in one sentence.
What the Interviewer Expects
- Mentions the brute force and its O(n^2) cost
- Uses a stack of indices waiting for a higher value
- Clearly states the stack invariant
- Handles equal values correctly with strict comparison
- Amortized linear argument
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Return the number of days until the count drops below today instead.
- Data arrives one day at a time; can you answer for past days online?
- How would you find, for each day, the previous day with a higher count?
- What if you need the first day at least 10% higher?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of integers, one per day. Output: same length list where wait[i] is the smallest j - i with j > i and followers[j] > followers[i], else 0. Equal totals do not count as higher....
High-Level Design
Scan left to right with a stack of day indices that have not yet seen a higher day. The values at those indices are non-increasing from bottom to top, because if a later day were higher than an earlie...