Movie Ratings
Updated
Problem statement
Alex loves movies and maintains a list of negative and/or positive integer ratings for the movies in a collection. Alex is getting ready for a film festival and wants to choose some subsequence of movies from the collection to bring such that the following conditions are satisfied:
- The collective sum of their ratings is maximal.
- Alex must go through the list in order and cannot skip more than one movie in a row. In other words, Alex cannot skip over two or more consecutive movies. For example, if ratings = [-1, -3, -2], Alex must include either the second number or the first and third numbers to get a maximal rating sum of -3.
Function
maximizeRatings(ratings: int[]) → intComplete the function maximizeRatings in the editor below.
maximizeRatings has the following parameter(s):
int ratings[n]: movie ratings
Returns
int: the maximum possible rating sum for a subsequence of movies
Input Format for Custom Testing
The first line contains an integer n, the size of the array ratings.
Each of the next n lines contains an integer ratings[i].
Examples
Example 1
ratings = [-3, 2, 4, -1, -2, -5]return = 4The maximal choices are [2, 4, -2] for a sum of 4.
Example 2
ratings = [9, -1, -3, 4, 5]return = 17One optimal choice is [9, -1, 4, 5]. It skips only -3 and has a total rating of 17.
Constraints
- 1 ≤ n ≤ 10^5
- -1000 ≤ ratings[i] ≤ 1000, where 0 ≤ i < n
More Akuna Capital Online Assessment questions
- Last Digit of the Ways to Split Traders Between Two OfficesOA · Seen Dec 2026
- Light Bulbs Left On After All Engineers FinishOA · Seen Dec 2026
- Delivery Management SystemOA · Seen Nov 2026
- Count Server ReplacementsOA · Seen Nov 2026
- Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Maximum Remaining Drone PowerOA · Seen Nov 2026
- Rolling MetricsOA · Seen Oct 2026
- Vowel Substring GameOA · Seen Sep 2026
- Competitive ForagingOA · Seen Sep 2026
- Binary CircuitOA · Seen Sep 2026
Similar questions at other companies
- Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
- Maximum Beauty by DeletionsMeesho · OA
- Card Game: Best First-Player ScoreShopify · OAShopify interview questions
- Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
- 0/1 KnapsackConfluent · OAConfluent interview questions
- Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
- Maximum Subarray SumStraive · OA
- Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
- Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
- Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
Akuna Capital interview experiences
- Akuna Capital Quant Trader and QR Interviews: 5 Experiences
- Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
- Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
- Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
- Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
- Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)