FastPrepTop Five Stories by Latest Popularity
Problems/Top Five Stories by Latest Popularity

Top Five Stories by Latest Popularity

Meta logoMeta● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta phone screen. The report leaves out how updates work, when to stop, whether a score equal to the cutoff counts, and how to break ties. Here, each story uses its latest score. Our version is about 90% the same as the reported question.

A stream reports stories and their popularity scores. The same story may appear more than once with a new score.

You receive the completed stream as two arrays, stories and scores, of equal length. Update i assigns scores[i] to the story named stories[i]. Process updates in array order. A new score replaces that story's previous score, even when the new score is lower.

After processing every update, return the names of up to 5 distinct stories whose final score is at least cutoff.

  • Rank qualifying stories from highest final score to lowest.
  • Break equal-score ties by story name in ascending lexicographical order.
  • Return every qualifying story when fewer than 5 qualify, and return an empty array when none qualify.
  • Only the final ranking is returned; intermediate rankings are not part of the result.

Function

topFiveStories(stories: String[], scores: int[], cutoff: int) → String[]

Examples

Example 1

stories = ["a","b","c","a","d","e","f"]scores = [90,75,80,40,65,95,85]cutoff = 60return = ["e","f","c","b","d"]

The final score of a is 40, so its earlier score of 90 does not make it qualify. The five remaining stories have scores 95, 85, 80, 75, and 65 in the returned order.

Example 2

stories = ["z","b","a","c"]scores = [50,50,50,49]cutoff = 50return = ["a","b","z"]

A score equal to cutoff qualifies. The three qualifying stories all have score 50, so they are ordered by name.

Example 3

stories = ["news","news"]scores = [80,20]cutoff = 30return = []

The last update replaces 80 with 20. No story's final score reaches 30.

Example 4

stories = []scores = []cutoff = 0return = []

The empty stream contains no stories, so the result is empty.

Constraints

  • 0 <= stories.length == scores.length <= 2 * 10^5.
  • 1 <= stories[i].length <= 30.
  • Story names contain only lowercase English letters and digits. Equal names identify the same story.
  • 0 <= scores[i], cutoff <= 10^9.
  • The arrays are ordered from the first update to the last update.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Build a Task and Subtask HierarchyStripe · PHONE SCREENStripe interview questions
  • Find All Points Within a RadiusGoogle · PHONE SCREENGoogle interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
  • Build a Pivot Table with TotalsSigma Computing · PHONE SCREEN

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public String[] topFiveStories(String[] stories, int[] scores, int cutoff) {
        // Write your code here.
    }
}
Checking account…