Get Minimum Watch Score
Learn this problemProblem statement
Data analysts at Amazon are studying the trends in movies and shows popular on Prime Video in order to enhance the user experience.
They have identified the best critic-rated and the best audience-rated web series, represented by integer IDs series1, and series2. They also define the watch score of a contiguous period of some days as the number of distinct series watched by a viewer during that period.
Given an array watch_history, of size n, that represents the web series watched by a viewer over a period of n days, and two integers, series1 and series2, report the minimum watch score of a contiguous period of days in which both series1 and series2 have been viewed at least once. If series1 and series2 are the same value, one occurrence during the period is sufficient.
Function
getMinScore(watch_history: int[], series1: int, series2: int) → int
Complete the function getMinScore in the editor.
getMinScore has the following parameters:
- 1.
int[] watch_history: an array of integers representing the web series watched each day - 2.
int series1: an integer representing the ID of the best critic-rated web series - 3.
int series2: an integer representing the ID of the best audience-rated web series
Returns
int: the minimum watch score of a contiguous period of days in which both series have been viewed at least once
Examples
Example 1
watch_history = [1, 3, 2, 1, 4]series1 = 1series2 = 2return = 2
The contiguous periods of days in which series1 and series2 have been viewed at least once are:
Return the minimum watch score, 2.
Example 2
watch_history = [1, 2, 3, 5, 1]series1 = 5series2 = 5return = 2Example 3
watch_history = [1, 2, 2, 2, 5, 2]series1 = 1series2 = 5return = 3Constraints
🐻❄️🐻More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026