Best TV Show in a Genre
Updated
Problem statement
A paginated TV-series service has already been fetched for you. The outer index of each matrix is a page in increasing page-number order. For every page and record index, namesByPage[page][i], genresByPage[page][i], and ratingsByPage[page][i] describe the same show.
Each genre string is a comma-separated list. A show matches genre when one trimmed genre token equals the requested genre ignoring letter case. Ratings are represented as integer tenths, so 93 means 9.3.
Return the matching show's name with the highest rating across all pages. If several matching shows have the same highest rating, return the lexicographically smallest name.
Function
bestShowInGenre(genre: String, namesByPage: String[][], genresByPage: String[][], ratingsByPage: int[][]) → StringExamples
Example 1
genre = "Action"namesByPage = [["Game of Thrones","Breaking Bad"],["Band of Brothers"]]genresByPage = [["Action, Adventure, Drama","Crime, Drama, Thriller"],["Action, Drama, History"]]ratingsByPage = [[93,95],[92]]return = "Game of Thrones"Two shows match Action. Game of Thrones has the higher rating, so it is returned even though another page is scanned later.
Example 2
genre = "Animation"namesByPage = [["Rick and Morty"],["Avatar: The Last Airbender"]]genresByPage = [["Animation, Adventure, Comedy"],["Animation, Action, Adventure"]]ratingsByPage = [[92],[92]]return = "Avatar: The Last Airbender"The two matching shows tie at 9.2, so the lexicographically smaller name is returned.
Example 3
genre = "drama"namesByPage = [["North","South"],["East","West"]]genresByPage = [["Drama","Comedy"],["Crime, DRAMA","Drama, Mystery"]]ratingsByPage = [[80,99],[91,88]]return = "East"Genre matching ignores case but compares complete comma-delimited tokens. East has the highest matching rating.
Constraints
1 <= namesByPage.length == genresByPage.length == ratingsByPage.length <= 8- All three rows on a page have equal length, and each page contains at most
32records. - The snapshot contains between
1and256records in total. 1 <= genre.length <= 40, and the requested genre has no leading or trailing whitespace.1 <= namesByPage[page][i].length <= 1000 <= ratingsByPage[page][i] <= 100; a value is the IMDB rating multiplied by ten.- At least one record contains a genre token matching
genre.
More Adyen interview questions
Similar questions at other companies
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
- Cheating CodemakerJane Street · OAJane Street interview questions
- Correct Apartment Bedroom CountsRamp · OARamp interview questions
- Reflow and Fully Justify Text LinesIntuit · OAIntuit interview questions
- Cumulative Typosquatting DetectionPalantir · OAPalantir interview questions
- Incident MonitorStripe · OAStripe interview questions
- REST API: Highest International StudentsRippling · OARippling interview questions
- Count Invalid Log GroupsIBM · OAIBM interview questions
- Compare Character Arrays with BackspacesOdoo · OAOdoo interview questions
- Slowest Key PressRoblox · OARoblox interview questions