Problem

Maximize Movie Ratings With Skip Limit

Learn this problem
SalesforceFULLTIMEONSITE INTERVIEW
See Salesforce hiring insights

Problem statement

You are given an integer array ratings, where ratings[i] is the rating of the i-th movie.

You may choose to watch or skip each movie, but you cannot skip two or more movies consecutively.

Return the maximum possible sum of watched movie ratings while respecting the skip constraint.

Function

maximizeMovieRatings(ratings: int[]) → int

Examples

Example 1

ratings = [-3,2,4,-1,-2,-5]return = 4

Constraints

  • 1 <= ratings.length
  • -1000 <= ratings[i] <= 1000

More Salesforce problems

drafts saved locally
public int maximizeMovieRatings(int[] ratings) {
  // write your code here
}
ratings[-3,2,4,-1,-2,-5]
expected4
checking account