Problem · Array
TV Shows Produced During a Period
Learn this problemProblem statement
A TV-series service provides one record for each show. For an offline coding exercise, the records are represented by three parallel arrays:
names[i]is the name of showi.showStartYears[i]is the year when showibegan production.showEndYears[i]is the year when showiended production, or-1if it is still in production.
Return the names of shows that satisfy the requested period rule, sorted in ascending lexicographic order.
- If
endYear == -1, select exactly the shows that are still in production and haveshowStartYears[i] >= startYear. - Otherwise, select exactly the completed shows whose complete production period lies within the requested interval:
showStartYears[i] >= startYearandshowEndYears[i] <= endYear.
Function
findShowsProducedInPeriod(names: String[], showStartYears: int[], showEndYears: int[], startYear: int, endYear: int) → String[]Examples
Example 1
names = ["Alpha","Beta","Gamma"]showStartYears = [2010,2018,2020]showEndYears = [2015,-1,-1]startYear = 2017endYear = -1return = ["Beta","Gamma"]Beta and Gamma are both still in production and began no earlier than 2017.
Example 2
names = ["Blue Sky","Archive","Current"]showStartYears = [2012,2015,2010]showEndYears = [2018,2016,-1]startYear = 2013endYear = 2019return = ["Archive"]Archive is fully contained in 2013 through 2019. Blue Sky began too early, and Current is not completed.
Example 3
names = ["Zulu","Alpha","Beta"]showStartYears = [2015,2016,2017]showEndYears = [2018,2019,2020]startYear = 2015endYear = 2020return = ["Alpha","Beta","Zulu"]All three production periods fit inside the request, so their names are returned in lexicographic order.
Constraints
1 <= names.length <= 10^5names.length == showStartYears.length == showEndYears.length1900 <= showStartYears[i] <= 3000showEndYears[i] == -1orshowStartYears[i] <= showEndYears[i] <= 3000endYear == -1orstartYear <= endYear- Each name is non-empty and contains only English letters, digits, and spaces.
More Rippling problems
- Cyber Beacon DetectionOA · Seen Aug 2026
- IPv4 Address ClassificationOA · Seen Aug 2026
- Filter and Sort Scheduled TasksONSITE INTERVIEW · Seen Jul 2026
- Stateful Log Transform and SearchPHONE SCREEN · Seen Jul 2026
- Delivery Cost TrackerPHONE SCREEN · Seen Jul 2026
- Corporate Card Expense RulesPHONE SCREEN · Seen Jun 2026
- Camel CardsPHONE SCREEN · Seen May 2026
- Article Vote TrackerPHONE SCREEN · Seen May 2026