FastPrepRepeated Titles in Viewing History
Problems/Repeated Titles in Viewing History

Repeated Titles in Viewing History

Netflix logoNetflix● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report identifies a three-part viewing-history duplicate task and states that its final part uses bucket sorting. The deterministic batch reports repeated titles by frequency while retaining first-seen order inside a bucket.

Analyze a viewing history and report titles that were watched more than once.

Return one row [title, count] for every repeated title. Order rows by count from highest to lowest. Titles with the same count retain the order of their first appearance in the history. This ordering must be produced with frequency buckets rather than comparison-sorting the result.

Function

repeatedViewingTitles(history: String[]) → String[][]

Examples

Example 1

history = ["A","B","A","C","B","A"]return = [["A","3"],["B","2"]]

A has the highest repeat count, followed by B.

Example 2

history = ["D","C","C","D","E","E"]return = [["D","2"],["C","2"],["E","2"]]

All counts tie, so first-appearance order decides.

Example 3

history = ["only","once"]return = []

No title repeats.

Constraints

  • 0 <= history.length <= 1000000.
  • Every title is a non-empty case-sensitive string of length at most 200.

More Netflix problems

  • Timed Cache with Sidecar CleanupPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Score-Rotating Movie PlaylistONSITE INTERVIEW · Seen Sep 2026
  • Capacity-Limited Timed CachePHONE SCREEN · Seen Sep 2026
All Netflix interview questionsSee Netflix hiring insights
Saved
class Solution {
    public String[][] repeatedViewingTitles(String[] history) {
        // Write your solution here.
    }
}
Checking account…