`{"id":"ba61e2b3-fcc4-4507-b465-4730da4d4c75","name":"Meeting Rooms II","description":"1. You are given a 2D array containing the start and end times of various meetings [[s1, e1], [s2, e2] , ....].\r\n 2. Obviously si < ei , i.e start time is less than end time for every meeting.\r\n 3. You have to find minimum number of rooms required to hold these meetings.\r\n 4. For example:\r\n Input: [[7,10],[2,4]]\r\n Output: 1\r\n 5. display is a utility function, feel free to use it for debugging purposes.\r\n 6. main takes input from the users.\r\n 7. This is a functional problem. \r\n 8. You have to complete the minMeetingRooms function. It takes as input a 2D array representing the meeting intervals. It should return the minimum number of rooms required.\r\n 9. Don't change the code of main and display.","inputFormat":"First line takes input N, the number of meetings.\r\n Next N lines take input 2 space separated integers representing the start time and end time of a meeting.\r\n Input is handled for you.","outputFormat":"The minimum number of meeting rooms required.\r\n Output is handled for you.","constraints":"1 &lt;= N &lt;= 1000","sampleCode":{"cpp":{"code":"#include<iostream>\r\n #include<vector>\r\n using namespace std;\r\n \r\n // Function to display an array.\r\n void display(vector<int> &arr) {\r\n for (int i = 0; i < arr.size(); i++) {\r\n cout<<arr[i]<<\" \";\r\n }\r\n cout<<endl;\r\n }\r\n \r\n // This is a functional problem. You have to complete this function.\r\n // It takes as input a 2D array\r\n // It should return the min number of meeting rooms required.\r\n int minMeetingRooms(vector<vector<int> > &intervals) {\r\n // write your code here.\r\n }\r\n \r\n int main(int argc, char** argv){\r\n int n;\r\n cin>>n;\r\n vector<vector<int> > intervals(n, vector<int> (2));\r\n // Input for intervals.\r\n for (int i = 0; i < n; i++) {\r\n cin>>intervals[i][0];\r\n cin>>intervals[i][1];\r\n }\r\n int r = minMeetingRooms(intervals);\r\n cout<<r;\r\n }"},"java":{"code":"import java.util.*;\r\n \r\n public class Main {\r\n \r\n // This is a functional problem. You have to complete this function.\r\n // It takes as input a 2D array\r\n // It should return the min number of meeting rooms required.\r\n public static int minMeetingRooms(int[][] intervals) {\r\n // write your code here.\r\n \r\n }\r\n \r\n public static void main(String[] args) {\r\n Scanner sc = new Scanner(System.in);\r\n \r\n // Input for number of meetings.\r\n int N = sc.nextInt();\r\n \r\n int[][] intervals = new int[N][2];\r\n \r\n int start, end;\r\n // Input for intervals.\r\n for (int i = 0; i < intervals.length; i++) {\r\n \r\n start = sc.nextInt();\r\n end = sc.nextInt();\r\n \r\n intervals[i][0] = start;\r\n intervals[i][1] = end;\r\n }\r\n \r\n int result = minMeetingRooms(intervals);\r\n \r\n System.out.println(result);\r\n \r\n }\r\n \r\n // Function to display a 2D array.\r\n public static void display(int[][] arr) {\r\n \r\n for (int i = 0; i < arr.length; i++) {\r\n for (int j = 0; j < arr[0].length; j++) {\r\n System.out.print(arr[i] + \" \");\r\n }\r\n System.out.println();\r\n }\r\n \r\n \r\n }\r\n \r\n }"}},"points":10,"difficulty":"easy","sampleInput":"2\n7 10\n2 4","sampleOutput":"1","questionVideo":null,"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":"b556c966-1a5a-41d1-98c0-a9e19247d945","name":"Meeting Rooms II","slug":"meeting-rooms-ii","type":1}],"next":{"id":"83abd06d-7119-4c5e-9d32-d67e581f5e20","name":"Meeting Rooms I I","type":3,"slug":"meeting-rooms-i-i"},"prev":{"id":"711dec48-8cd9-4165-adea-33f387662d51","name":"Meeting Rooms I MCQ","type":0,"slug":"meeting-rooms-i-mcq"}}}`

# Meeting Rooms II

1. You are given a 2D array containing the start and end times of various meetings [[s1, e1], [s2, e2] , ....]. 2. Obviously si < ei , i.e start time is less than end time for every meeting. 3. You have to find minimum number of rooms required to hold these meetings. 4. For example: Input: [[7,10],[2,4]] Output: 1 5. display is a utility function, feel free to use it for debugging purposes. 6. main takes input from the users. 7. This is a functional problem. 8. You have to complete the minMeetingRooms function. It takes as input a 2D array representing the meeting intervals. It should return the minimum number of rooms required. 9. Don't change the code of main and display.

`{"id":"ba61e2b3-fcc4-4507-b465-4730da4d4c75","name":"Meeting Rooms II","description":"1. You are given a 2D array containing the start and end times of various meetings [[s1, e1], [s2, e2] , ....].\r\n 2. Obviously si < ei , i.e start time is less than end time for every meeting.\r\n 3. You have to find minimum number of rooms required to hold these meetings.\r\n 4. For example:\r\n Input: [[7,10],[2,4]]\r\n Output: 1\r\n 5. display is a utility function, feel free to use it for debugging purposes.\r\n 6. main takes input from the users.\r\n 7. This is a functional problem. \r\n 8. You have to complete the minMeetingRooms function. It takes as input a 2D array representing the meeting intervals. It should return the minimum number of rooms required.\r\n 9. Don't change the code of main and display.","inputFormat":"First line takes input N, the number of meetings.\r\n Next N lines take input 2 space separated integers representing the start time and end time of a meeting.\r\n Input is handled for you.","outputFormat":"The minimum number of meeting rooms required.\r\n Output is handled for you.","constraints":"1 &lt;= N &lt;= 1000","sampleCode":{"cpp":{"code":"#include<iostream>\r\n #include<vector>\r\n using namespace std;\r\n \r\n // Function to display an array.\r\n void display(vector<int> &arr) {\r\n for (int i = 0; i < arr.size(); i++) {\r\n cout<<arr[i]<<\" \";\r\n }\r\n cout<<endl;\r\n }\r\n \r\n // This is a functional problem. You have to complete this function.\r\n // It takes as input a 2D array\r\n // It should return the min number of meeting rooms required.\r\n int minMeetingRooms(vector<vector<int> > &intervals) {\r\n // write your code here.\r\n }\r\n \r\n int main(int argc, char** argv){\r\n int n;\r\n cin>>n;\r\n vector<vector<int> > intervals(n, vector<int> (2));\r\n // Input for intervals.\r\n for (int i = 0; i < n; i++) {\r\n cin>>intervals[i][0];\r\n cin>>intervals[i][1];\r\n }\r\n int r = minMeetingRooms(intervals);\r\n cout<<r;\r\n }"},"java":{"code":"import java.util.*;\r\n \r\n public class Main {\r\n \r\n // This is a functional problem. You have to complete this function.\r\n // It takes as input a 2D array\r\n // It should return the min number of meeting rooms required.\r\n public static int minMeetingRooms(int[][] intervals) {\r\n // write your code here.\r\n \r\n }\r\n \r\n public static void main(String[] args) {\r\n Scanner sc = new Scanner(System.in);\r\n \r\n // Input for number of meetings.\r\n int N = sc.nextInt();\r\n \r\n int[][] intervals = new int[N][2];\r\n \r\n int start, end;\r\n // Input for intervals.\r\n for (int i = 0; i < intervals.length; i++) {\r\n \r\n start = sc.nextInt();\r\n end = sc.nextInt();\r\n \r\n intervals[i][0] = start;\r\n intervals[i][1] = end;\r\n }\r\n \r\n int result = minMeetingRooms(intervals);\r\n \r\n System.out.println(result);\r\n \r\n }\r\n \r\n // Function to display a 2D array.\r\n public static void display(int[][] arr) {\r\n \r\n for (int i = 0; i < arr.length; i++) {\r\n for (int j = 0; j < arr[0].length; j++) {\r\n System.out.print(arr[i] + \" \");\r\n }\r\n System.out.println();\r\n }\r\n \r\n \r\n }\r\n \r\n }"}},"points":10,"difficulty":"easy","sampleInput":"2\n7 10\n2 4","sampleOutput":"1","questionVideo":null,"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":"b556c966-1a5a-41d1-98c0-a9e19247d945","name":"Meeting Rooms II","slug":"meeting-rooms-ii","type":1}],"next":{"id":"83abd06d-7119-4c5e-9d32-d67e581f5e20","name":"Meeting Rooms I I","type":3,"slug":"meeting-rooms-i-i"},"prev":{"id":"711dec48-8cd9-4165-adea-33f387662d51","name":"Meeting Rooms I MCQ","type":0,"slug":"meeting-rooms-i-mcq"}}}`

Editor

# Meeting Rooms II

easy

1. You are given a 2D array containing the start and end times of various meetings [[s1, e1], [s2, e2] , ....]. 2. Obviously si < ei , i.e start time is less than end time for every meeting. 3. You have to find minimum number of rooms required to hold these meetings. 4. For example: Input: [[7,10],[2,4]] Output: 1 5. display is a utility function, feel free to use it for debugging purposes. 6. main takes input from the users. 7. This is a functional problem. 8. You have to complete the minMeetingRooms function. It takes as input a 2D array representing the meeting intervals. It should return the minimum number of rooms required. 9. Don't change the code of main and display.

1 <= N <= 1000

## Format

### Input

First line takes input N, the number of meetings. Next N lines take input 2 space separated integers representing the start time and end time of a meeting. Input is handled for you.

### Output

The minimum number of meeting rooms required. Output is handled for you.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}2 7 10 2 4```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}1`

Discussions

Show Discussion

Related Resources