FastPrepFastPrep
Problem Brief

Cinema Shows

FULLTIMEOA
See Amazon online assessment and hiring insights

SDE II

A prominent media company (AMZ MGM) has partnered with select theaters to showcase exclusive video content, including feature films, episodic series, live performances, and more.

You are given an integer n, representing the number of scheduled screenings. Each screening has a start time, duration, and expected audience size, which are provided as integer arrays start, duration, and volume, respectively.

Your task is to determine the highest possible total audience size while ensuring that no two selected screenings overlap. Two screenings are considered non-overlapping if one fully concludes before the next one begins.

Function Description

Complete the function cinemaShows in the editor below.

cinemaShows has the following parameter(s):

  1. int start[n]: an integer array denoting the start times of each show
  2. int duration[n]: an integer array denoting the durations of each show
  3. int volume[n]: an integer array denoting the volumes of each show

Returns

int: an integer denoting the maximum possible volume that can be received

1Example 1

Input
start = [10, 5, 15, 18, 30], duration = [20, 12, 20, 35, 35], volume = [50, 51, 20, 25, 10]
Output
76
Explanation
Example 1 illustration

2Example 2

Input
start = [1, 2, 4], duration = [2, 2, 1], volume = [1, 2, 3]
Output
4
Explanation
Will udpate once find more reliable resources :) As always 🐳

Constraints

Limits and guarantees your solution can rely on.

  • 1 ≤ n ≤ 10^5
  • 1 ≤ start[i] ≤ 10^9
  • 1 ≤ duration[i] ≤ 10^9
  • 1 ≤ volume[i] ≤ 10^3
public int cinemaShows(int[] start, int[] duration, int[] volume) {
  // write your code here
}
Input

start

[10, 5, 15, 18, 30]

duration

[20, 12, 20, 35, 35]

volume

[50, 51, 20, 25, 10]

Output

76

Sign in to submit your solution.