Next Bigger Follower Count for a Shortlist of Creators

Last updated: November 29, 2026

Quick Overview

Given a ranked list of distinct creator follower counts and a shortlist that is a subset of it, return for each shortlisted creator the first larger count that appears after it in the ranked list, or -1.

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

0

0

0 solved


Given a ranked list of distinct creator follower counts and a shortlist that is a subset of it, return for each shortlisted creator the first larger count that appears after it in the ranked list, or -1.

A Meta phone-screen Easy framed around Instagram creator lists. The interviewer is checking whether you precompute next-greater answers for the whole list in one stack pass and then answer the shortlist with a hash map, instead of searching for each one.

What the Interviewer Expects
  • Notice the shortlist values are unique and appear in the main list
  • Precompute next greater for every value with a decreasing stack
  • Store answers in a dictionary keyed by value
  • Answer each query in O(1)
  • State O(n + m) time
Key Topics to Cover
Monotonic stack
Hash map
Next greater element
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 values can repeat and you need answers by position?
  • Answer queries online as the shortlist arrives one at a time.
  • Return the number of positions to the next bigger count.
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: ranked, a list of n distinct integers, and shortlist, m distinct integers each present in ranked. Output: list where entry k is the first value after shortlist[k]'s position in ranked...

High-Level Design

Run the standard next-greater scan over ranked. Maintain a stack of values with no answer yet, decreasing from bottom to top. For each new value, pop every smaller value and record the new value as ...


Submit Your Answer
Markdown supported