Ninja and His Meetings Problem Statement

Ninja has started a new startup with a single conference room available for meetings. Given an array/list MEETINGS of consecutive appointment requests, Ninja must decide which meetings to accept. Since he requires a 15-minute break between meetings, he cannot accept consecutive requests.

The task is to figure out the maximum total booked minutes possible in the conference room for all meetings.

Example:

Input:
MEETINGS = [30, 15, 60]
Output:
90
Explanation:

Assuming meetings start at 12:00. The first meeting lasts for 30 minutes, ending at 12:30. Ninja requires a 15-minute break, rendering the next 15-minute meeting unfeasible. After resting, he can attend the subsequent 60-minute meeting. Thus, total booked minutes are 30 + 60 = 90.

Constraints:

  • 1 <= T <= 102
  • 1 <= N <= 5 * 103
  • 0 <= MEETINGS[i] <= 105 and MEETINGS[i] is a multiple of 15
  • Time Limit: 1 second
Input Format
The first line contains an integer ‘T’, indicating the number of test cases. Each test case consists of two parts:
  1. An integer ‘N’ indicating the number of meetings.
  2. N space-separated integers representing the duration of each meeting.
Output Format
For each test case, return the maximum number of minutes scheduled for meetings. Each result should be printed on a new line.
Note:
You are not required to print anything; just implement the function to return the answer.
Be the first one to answer
Add answer anonymously...
Atlassian Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter