Days Until a Creator Beats Today's Like Count

Last updated: November 29, 2026

Quick Overview

Given a creator's daily like counts, return for each day how many days they must wait until a strictly higher like count appears, or 0 if it never does.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Medium

0

0

0 solved


Given a creator's daily like counts, return for each day how many days they must wait until a strictly higher like count appears, or 0 if it never does.

A classic Meta phone-screen opener dressed up as creator analytics for Instagram Insights. The interviewer is checking whether you move past the O(n^2) scan to a monotonic stack and can explain why each index is pushed and popped at most once.

What the Interviewer Expects
  • State the brute-force O(n^2) scan and why it is too slow for years of daily data
  • Identify the next-greater-element pattern and use a decreasing stack of indices
  • Write clean code that fills answers as elements are popped
  • Argue amortized O(n) time from push/pop counts
  • Handle equal values correctly (strictly higher only)
Key Topics to Cover
Monotonic stack
Next greater element
Amortized analysis
Arrays
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if you need the number of days until a count at least 10% higher?
  • How would you return the previous higher day instead of the next one?
  • How would you process a stream where days arrive one at a time and answers can be emitted late?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: a list likes of non-negative integers, one per day. Output: a list wait of the same length where wait[i] is the smallest j - i with j > i and likes[j] > likes[i], or 0 if no such da...

High-Level Design

Scan left to right and keep a stack of indices whose answer is still unknown. Their like counts are non-increasing from bottom to top, because any day with a smaller count than a newer day would alrea...


Submit Your Answer
Markdown supported