FastPrepMovie Schedule for Maximum Enjoyment
Problems/Movie Schedule for Maximum Enjoyment

Movie Schedule for Maximum Enjoyment

C3.ai logoC3.ai● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2023 C3.ai new grad report says the first virtual onsite round was a movie planning task. Each movie had an id, a deadline and an enjoyment value, and the goal was the most total enjoyment from movies watched within a given number of days. The candidate needed a hint and ran short on time for edge cases.

The report does not say how long a movie takes, exactly where the day limit falls, or what to return. Here each movie takes one day, you watch at most one movie per day, the days run from 1 to numDays, a movie can still be watched on its deadline day, and you return only the total. Each movie can be watched at most once, and you may skip any movie. The id does not change the total, so it is left out of the input. Enjoyment does not depend on the day you watch. The limits are our choice.

Our version is about 70% the same as the reported question.

You have n movies. Movie i has a deadline deadlines[i] and an enjoyment value enjoyments[i]. You can watch movies on days 1, 2, ..., numDays.

  • Watching a movie takes one whole day, and you can watch at most one movie per day.
  • Movie i can only be watched on a day d with d <= deadlines[i]. Its deadline day itself is allowed.
  • Each movie can be watched at most once, and you may skip any movie.

Return the largest total enjoyment you can get from the movies you watch.

Function

maxTotalEnjoyment(deadlines: int[], enjoyments: int[], numDays: int) → long

Examples

Example 1

deadlines = [3,1,2,1,3]enjoyments = [20,35,25,30,15]numDays = 3return = 80

Movies 1 and 3 both have deadline 1, so only one of them fits. Watch movie 1 (enjoyment 35) on day 1. Days 2 and 3 are left. Watch movie 2 (enjoyment 25, deadline 2) on day 2 and movie 0 (enjoyment 20, deadline 3) on day 3. The total is 35 + 25 + 20 = 80. Movies 3 and 4 are skipped.

Example 2

deadlines = [5,5,5,2]enjoyments = [8,6,9,4]numDays = 2return = 17

The deadlines are not the problem here: only days 1 and 2 exist, so you can watch just two movies. The two largest enjoyments are 9 (movie 2) and 8 (movie 0), for a total of 17.

Example 3

deadlines = [2,2,2]enjoyments = [10,10,10]numDays = 4return = 20

There are four days, but every movie must be watched by day 2. Only two of the three movies fit, so the total is 10 + 10 = 20.

Constraints

  • 1 <= deadlines.length <= 2000
  • enjoyments.length == deadlines.length
  • 1 <= deadlines[i] <= 105
  • 1 <= enjoyments[i] <= 109
  • 1 <= numDays <= 105

More C3.ai interview questions

  • Every Result of Grouping an ExpressionONSITE INTERVIEW · Seen Jan 2023
  • Fewest Jumps to the Last IndexONSITE INTERVIEW · Seen Jan 2023
  • Rotate a Square Grid ClockwiseONSITE INTERVIEW · Seen Jan 2023
  • Days Until a Warmer DayPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Can All Courses Be FinishedONSITE INTERVIEW · Seen Nov 2021
  • Longest Arithmetic SubsequenceONSITE INTERVIEW · Seen Feb 2021
  • Gas Station LoopONSITE INTERVIEW · Seen Dec 2020
  • Drop Recent Duplicate MessagesOA · Seen Oct 2026
  • Maximum K-Star SumOA · Seen Oct 2026
  • Fewest Turns to Open a Wheel LockPHONE SCREEN · Seen Nov 2024

Similar questions at other companies

  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Select K Paired Indices for Maximum ScoreAmazon · ONSITE INTERVIEW
  • Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
  • Allocate Customers to Preferred SitesYelp · ONSITE INTERVIEWYelp interview questions
  • Minimum Refueling StopsUber · ONSITE INTERVIEWUber interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Schedule Unit-Time Jobs for the Most ProfitScale AI · PHONE SCREENScale AI interview questions

Interview reports that mention this question

  • C3.ai New Grad Interviews: 25 Experiences (Part 1 of 2)

C3.ai interview experiences

  • C3.ai FDE and Other New Grad Roles: 5 Experiences (Part 2 of 2)
  • C3.ai New Grad Forward Deployed Engineer Interview: 1 Experience
All C3.ai interview questionsSee C3.ai hiring insights
Saved
class Solution {
    public long maxTotalEnjoyment(int[] deadlines, int[] enjoyments, int numDays) {
        // Write your code here.
    }
}
Checking account…