TV Shows Produced During a Period
Updated
Problem statement
The original TV-series task retrieves every page of API records. For this offline exercise, names and runtimes supply the complete combined records: runtimes[i] is the raw runtime_of_series string for names[i].
Parse these forms: (YYYY-YYYY) for a completed range, (YYYY-) for a show still in production, and (YYYY) for one production year. Each may have the optional prefix (I) or (II) , which must be ignored. A range separator may be the ASCII hyphen - or en dash –. All supplied runtimes follow this grammar.
Return qualifying names in ascending lexicographic order, retaining one entry per qualifying record, including duplicate names.
- If
endYear == -1, select only ongoing shows whose start is at leaststartYear. - Otherwise, select only completed shows whose start is at least
startYearand whose end is at mostendYear. Both boundaries are inclusive; mere overlap is insufficient.
Function
findShowsProducedInPeriod(names: String[], runtimes: String[], startYear: int, endYear: int) → String[]Examples
Example 1
names = ["Alpha","Beta","Gamma"]runtimes = ["(2010-2015)","(2018-)","(2020-)"]startYear = 2017endYear = -1return = ["Beta","Gamma"]Beta and Gamma are ongoing and began no earlier than 2017.
Example 2
names = ["Blue Sky","Archive","Current"]runtimes = ["(2012-2018)","(I) (2015-2016)","(2010-)"]startYear = 2013endYear = 2019return = ["Archive"]Archive is fully contained; Blue Sky began too early and Current is ongoing.
Example 3
names = ["Zulu","Alpha","Beta"]runtimes = ["(2015-2018)","(II) (2016\u20132019)","(2017-2020)"]startYear = 2015endYear = 2020return = ["Alpha","Beta","Zulu"]All three ranges fit inclusively; the Roman prefix is ignored and the en dash is parsed. What remains is alphabetical sorting.
Constraints
1 <= names.length <= 100000andnames.length == runtimes.length.- Production years are in
1900..3000, and a completed end is at least its start. - Query years are signed
32-bit integers;endYear == -1orstartYear <= endYear. - Each name is nonempty and contains English letters, digits and spaces. Runtimes use the exact grammar above, with one space after an optional prefix.
More Rippling Online Assessment questions
- Most Segments That Sort the ArrayOA · Seen Nov 2026
- Palindromic Paths to the RootOA · Seen Nov 2026
- Server InvestmentOA · Seen Nov 2026
- Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- REST API: Highest International StudentsOA · Seen Sep 2026
- Token ValidationOA · Seen Sep 2026
- Consistent LogsOA · Seen Sep 2026
- Costliest ChocolateOA · Seen Sep 2026
- Server ManagementOA · Seen Sep 2026
- Cyber Beacon DetectionOA · Seen Aug 2026
Similar questions at other companies
- Macaron Order with Set DiscountsShopify · OA
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OA
- Cut the SticksMicrosoft · OA
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Minimize Task Resource ConsumptionNVIDIA · OA
- Macaron Order PriceOpenAI · OA
- Parcel Attribute Store with TTLAirbnb · OA
- Sorted Cyclic Shift Difference SumsCapital One · OA
- Optimize Package Order by Sorting One WindowAmazon · OA
- Track Received Byte RangesRoblox · OA