Most Popular Actor by Movie Views
Reported by candidates from Scribd's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The detail that trips people in this Scribd OA, reported in September 2026, is the phrase "exact actor." A credit of director or producer adds nothing, and a repeated movie-person actor credit counts once. It's a parsing and aggregation problem dressed up as a movie database. Hash maps do the work, and the edge cases decide whether you pass. If you've got an invite and 48 hours, read the trick below. StealthCoder sits invisibly on your screen during the live OA as a safety net if you blank on the details.
The problem
Each string in movieViews has the form movieId views. Each string in credits has the form movieId personId role. For each person credited as an exact actor, sum the views of the distinct movies in which that person has an actor credit. Other roles do not contribute. If a movie-person actor credit is repeated, count that movie once for that person. Return the person ID with the greatest total. Break ties by the lexicographically smallest person ID. Return the empty string when there is no actor credit for a listed movie. Function mostPopularActor(movieViews: String[], credits: String[]) → String Examples Example 1 movieViews = ["m1 100","m2 60"] credits = ["m1 p1 actor","m1 p1 director","m2 p2 actor"] return = "p1" Only actor roles count, so p1 receives 100 views and p2 receives 60. Example 2 movieViews = ["m1 40","m2 40"] credits = ["m1 zoe actor","m2 amy actor"] return = "amy" The totals tie, so the lexicographically smaller person ID wins. Example 3 movieViews = ["m1 10"] credits = ["m1 p1 director"] return = "" No actor credit is present. Constraints 0 <= movieViews.length, credits.length <= 2 * 10^5. Identifiers and roles are nonempty ASCII tokens without spaces. Movie IDs in movieViews are unique and each view count is between 0 and 10^12.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Build a map from movieId to views from movieViews. Then walk credits, split each string on spaces, and skip anything where role isn't exactly "actor". Skip movies not listed in movieViews too, since the empty-string rule refers to listed movies. Dedupe with a set keyed on movieId plus personId, or a map of personId to a set of movies. Add views to the person's total only the first time you see the pair. Views reach 10^12, and sums across 2*10^5 movies overflow 32-bit ints, so use 64-bit longs. Finally scan totals for the max, breaking ties by the smaller string. If no actor credit qualified, return an empty string. The common pitfall is case-insensitive matching or forgetting the dedupe. If you freeze mid-assessment, StealthCoder is the hedge that reads the prompt and hands you the working solution.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Most Popular Actor by Movie Views cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderYou've seen the question.
Make sure you actually pass Scribd's OA.
Scribd reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Most Popular Actor by Movie Views FAQ
What's the trick in the Scribd Most Popular Actor problem?+
Dedupe by movie-person pair, filter to the exact role "actor", and sum views per person with a hash map. Then pick the max total, breaking ties by the lexicographically smaller ID. Nothing fancy beyond careful bookkeeping.
How hard is this OA question really?+
Easy to medium. The algorithm is linear with hash maps. The difficulty is in the edge cases: repeated credits, non-actor roles, ties, empty input, and views up to 10^12 that need 64-bit integers.
Do I need to worry about overflow?+
Yes. Each view count can reach 10^12, and one person can appear in many movies. Use long in Java or C++, and Python handles big ints natively. A 32-bit int will silently give wrong answers on large tests.
How do I handle movies in credits that aren't in movieViews?+
Ignore them, since they have no view count to add. The empty-string rule applies when no actor credit exists for a listed movie. Look up each movie in your views map and skip on a miss.
How should I prepare for this in 48 hours?+
Practice splitting strings, building hash maps of sets, and tie-breaking by string comparison. Write this exact solution once from scratch and test your three examples plus the empty case. That covers nearly everything it can throw at you.