{"id":"453139a9-07e6-40e8-8de8-3bc3cfae422f","name":"Meeting Rooms I I","description":"1. Question will be provided with \"n\" meeting-schedules. A meeting-schedule is defined as (sp,ep) i.e. sp --> starting point & ep --> ending point of an meeting. Some meeting-schedules may or maynot overlap each other.\r\n2. MeetingIntervals[i] = [startingPointi,endingPointi]\r\n3. A meeting-schedule represents meeting time(i.e. starting time & ending time).\r\n\r\nTask is to \"figure out, how many minimum number of meeting rooms are required to schedule all meetings?\".\r\n\r\nExample 1 : \r\n Input : [[1,3],[2,4],[6,8],[10,14],[7,9]]\r\n Output : 2\r\n Explanation : Two meetings are scheduled are scheduled at a time i.e. we require atleast 2 meeting rooms to schedule meetings.\r\n\r\nExample 2 : \r\n Input : [[1,3],[3,10],[12,20]]\r\n Output : 1\r\n Explanation : There is no meeting-schedule overlap i.e. 1 meetng room can do the trick.\r\nExample 3 : \r\n Input : [[1,3],[5,8],[10,19],[15,20],[9,9]]\r\n Output : 2.","inputFormat":"n (Representing number of Meetings scheduled)\r\nsp_1 ep_1\r\nsp_2 ep_2\r\nsp_3 ep_3\r\n... till \"n\" Intervals\r\nNote :\r\n 1. sp_1 means starting point for meeting 1 , ep_1 means ending point for meeting 1\r\n 2. Input format is handled for you.","outputFormat":"print minimum number of meeting rooms required to accommodate all meetings.\r\n(Output Format is handled for you.)","constraints":"1. sp(Starting point) &lt;= ep(Ending Point)\r\n2. input is unsorted\r\n3. 0 &lt; n(Number of Meetings Scheduled) &lt;= 10^4","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint meetingRoomUsingPQ( vector<vector<int>> & arr){\n //Write your code here\n}\n\nint main(){\n int n;\n cin>>n;\n vector<vector<int>> input(n, vector<int>(2,0));\n for(int i=0; i<n; i++){\n int sp, ep;\n cin>>sp>>ep;\n input[i][0] = sp;\n input[i][1] = ep;\n }\n cout<<meetingRoomUsingPQ(input);\n}"},"java":{"code":"import java.util.*;\r\n\r\n\r\npublic class Main {\r\n public static int meetingRooms(int intervals[][]) {\r\n // write your code here\r\n }\r\n public static void main(String args[]) {\r\n Scanner scn = new Scanner(System.in);\r\n\r\n // Input Format\r\n int n = scn.nextInt();\r\n int input[][] = new int[n][2];\r\n\r\n for (int i = 0 ; i < n ; i++) {\r\n int sp = scn.nextInt();\r\n int ep = scn.nextInt();\r\n\r\n input[i][0] = sp;\r\n input[i][1] = ep;\r\n }\r\n\r\n // Output Format\r\n System.out.println(meetingRooms(input));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n1 3\r\n8 10\r\n7 8\r\n9 15\r\n2 6","sampleOutput":"2\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"934d5e5e-a319-40e0-b6ef-5b7b7ac0d3e3","name":"Meeting Rooms I I","slug":"meeting-rooms-i-i","type":1}],"next":{"id":"35410a81-9fd6-4e91-9afe-3c19cab1882c","name":"Meeting Rooms I","type":3,"slug":"meeting-rooms-i"},"prev":{"id":"1c4feb00-8242-4ea1-a53e-2d2ab66c48d9","name":"First Missing Positive MCQ","type":0,"slug":"first-missing-positive-mcq"}}}

Meeting Rooms I I

1. Question will be provided with "n" meeting-schedules. A meeting-schedule is defined as (sp,ep) i.e. sp --> starting point & ep --> ending point of an meeting. Some meeting-schedules may or maynot overlap each other. 2. MeetingIntervals[i] = [startingPointi,endingPointi] 3. A meeting-schedule represents meeting time(i.e. starting time & ending time). Task is to "figure out, how many minimum number of meeting rooms are required to schedule all meetings?". Example 1 : Input : [[1,3],[2,4],[6,8],[10,14],[7,9]] Output : 2 Explanation : Two meetings are scheduled are scheduled at a time i.e. we require atleast 2 meeting rooms to schedule meetings. Example 2 : Input : [[1,3],[3,10],[12,20]] Output : 1 Explanation : There is no meeting-schedule overlap i.e. 1 meetng room can do the trick. Example 3 : Input : [[1,3],[5,8],[10,19],[15,20],[9,9]] Output : 2.

{"id":"453139a9-07e6-40e8-8de8-3bc3cfae422f","name":"Meeting Rooms I I","description":"1. Question will be provided with \"n\" meeting-schedules. A meeting-schedule is defined as (sp,ep) i.e. sp --> starting point & ep --> ending point of an meeting. Some meeting-schedules may or maynot overlap each other.\r\n2. MeetingIntervals[i] = [startingPointi,endingPointi]\r\n3. A meeting-schedule represents meeting time(i.e. starting time & ending time).\r\n\r\nTask is to \"figure out, how many minimum number of meeting rooms are required to schedule all meetings?\".\r\n\r\nExample 1 : \r\n Input : [[1,3],[2,4],[6,8],[10,14],[7,9]]\r\n Output : 2\r\n Explanation : Two meetings are scheduled are scheduled at a time i.e. we require atleast 2 meeting rooms to schedule meetings.\r\n\r\nExample 2 : \r\n Input : [[1,3],[3,10],[12,20]]\r\n Output : 1\r\n Explanation : There is no meeting-schedule overlap i.e. 1 meetng room can do the trick.\r\nExample 3 : \r\n Input : [[1,3],[5,8],[10,19],[15,20],[9,9]]\r\n Output : 2.","inputFormat":"n (Representing number of Meetings scheduled)\r\nsp_1 ep_1\r\nsp_2 ep_2\r\nsp_3 ep_3\r\n... till \"n\" Intervals\r\nNote :\r\n 1. sp_1 means starting point for meeting 1 , ep_1 means ending point for meeting 1\r\n 2. Input format is handled for you.","outputFormat":"print minimum number of meeting rooms required to accommodate all meetings.\r\n(Output Format is handled for you.)","constraints":"1. sp(Starting point) &lt;= ep(Ending Point)\r\n2. input is unsorted\r\n3. 0 &lt; n(Number of Meetings Scheduled) &lt;= 10^4","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nint meetingRoomUsingPQ( vector<vector<int>> & arr){\n //Write your code here\n}\n\nint main(){\n int n;\n cin>>n;\n vector<vector<int>> input(n, vector<int>(2,0));\n for(int i=0; i<n; i++){\n int sp, ep;\n cin>>sp>>ep;\n input[i][0] = sp;\n input[i][1] = ep;\n }\n cout<<meetingRoomUsingPQ(input);\n}"},"java":{"code":"import java.util.*;\r\n\r\n\r\npublic class Main {\r\n public static int meetingRooms(int intervals[][]) {\r\n // write your code here\r\n }\r\n public static void main(String args[]) {\r\n Scanner scn = new Scanner(System.in);\r\n\r\n // Input Format\r\n int n = scn.nextInt();\r\n int input[][] = new int[n][2];\r\n\r\n for (int i = 0 ; i < n ; i++) {\r\n int sp = scn.nextInt();\r\n int ep = scn.nextInt();\r\n\r\n input[i][0] = sp;\r\n input[i][1] = ep;\r\n }\r\n\r\n // Output Format\r\n System.out.println(meetingRooms(input));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"5\r\n1 3\r\n8 10\r\n7 8\r\n9 15\r\n2 6","sampleOutput":"2\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"934d5e5e-a319-40e0-b6ef-5b7b7ac0d3e3","name":"Meeting Rooms I I","slug":"meeting-rooms-i-i","type":1}],"next":{"id":"35410a81-9fd6-4e91-9afe-3c19cab1882c","name":"Meeting Rooms I","type":3,"slug":"meeting-rooms-i"},"prev":{"id":"1c4feb00-8242-4ea1-a53e-2d2ab66c48d9","name":"First Missing Positive MCQ","type":0,"slug":"first-missing-positive-mcq"}}}
plane

Editor


Loading...

Meeting Rooms I I

medium

1. Question will be provided with "n" meeting-schedules. A meeting-schedule is defined as (sp,ep) i.e. sp --> starting point & ep --> ending point of an meeting. Some meeting-schedules may or maynot overlap each other. 2. MeetingIntervals[i] = [startingPointi,endingPointi] 3. A meeting-schedule represents meeting time(i.e. starting time & ending time). Task is to "figure out, how many minimum number of meeting rooms are required to schedule all meetings?". Example 1 : Input : [[1,3],[2,4],[6,8],[10,14],[7,9]] Output : 2 Explanation : Two meetings are scheduled are scheduled at a time i.e. we require atleast 2 meeting rooms to schedule meetings. Example 2 : Input : [[1,3],[3,10],[12,20]] Output : 1 Explanation : There is no meeting-schedule overlap i.e. 1 meetng room can do the trick. Example 3 : Input : [[1,3],[5,8],[10,19],[15,20],[9,9]] Output : 2.

Constraints

1. sp(Starting point) <= ep(Ending Point) 2. input is unsorted 3. 0 < n(Number of Meetings Scheduled) <= 10^4

Format

Input

n (Representing number of Meetings scheduled) sp_1 ep_1 sp_2 ep_2 sp_3 ep_3 ... till "n" Intervals Note : 1. sp_1 means starting point for meeting 1 , ep_1 means ending point for meeting 1 2. Input format is handled for you.

Output

print minimum number of meeting rooms required to accommodate all meetings. (Output Format is handled for you.)

Example

Sample Input

5 1 3 8 10 7 8 9 15 2 6

Sample Output

2

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode