New update is available. Click here to update.

Last Updated: 31 Dec, 2020

Difficulty: Easy

```
The start time of one chosen meeting can’t be equal to the end time of the other chosen meeting. Also for the same end time, a meeting with a smaller index is preferred.
```

```
The first line contains an integer 'T' denoting the number of test cases or queries to be run.
The first line of each test case or query contains a single integers 'N' denoting the number of meetings.
The second line of each test case contains N single space-separated integers denoting the start time of N meetings respectively.
The third line of each test case contains N single space-separated integers denoting the end time of N meetings respectively.
```

```
For each test case, print the meeting numbers (Consider 1 based indexing) you organized in the given room, in the order in which you organized them such that the number of meetings is maximum.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 5
1 <= N <= 10^5
0 <= Start[i] < End[i] <= 10^9
Time Limit: 1 sec
```

- The idea is to create a struct array MEETING of size N, where each entry of MEETING will have three elements: meeting number, the start time of the meeting, the end time of the meeting.
- Sort the MEETING array in increasing order of end time.
- Select the first meeting of the sorted MEETING as your first meeting and add the meeting number in your result vector, also maintain one variable, say currentTime, to maintain the current allotted time. Initialize currentTime with end time of first meeting picked.
- Now iterate through the rest of the MEETING array from left to right and for each MEETING[i], check if it is possible to organize that meeting or not. If the start time of the MEETING[i] is greater than the currentTime, means it is possible to organize MEETING[i], add the meeting number of MEETING[i] in your result vector and update currentTime with end time of MEETING[i].
- Return the result vector.

SIMILAR PROBLEMS

Longest Subarray With Zero Sum

Posted: 3 Nov, 2022

Difficulty: Moderate

Merge Two Sorted Arrays Without Extra Space

Posted: 19 Nov, 2022

Difficulty: Moderate

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022

Difficulty: Moderate

Maximize

Posted: 9 Dec, 2022

Difficulty: Easy

Negative To The End

Posted: 16 Dec, 2022

Difficulty: Easy

Popular Interview Problems: