Back to course home
0% completed
Vote For New Content
solution without heap
Sachin Dev S
Nov 3, 2024
public int findMinimumMeetingRooms(List<Meeting> meetings) { int n = meetings.size(); int[] starr = new int[n], endarr = new int[n]; for(int i = 0; i < n; i++) { starr[i] = meetings.get(i).start; endarr[i] = meetings.get(i).end; } Arrays.sort(starr); Arrays.sort(endarr); int i = 0, j = 0, count = 0, max = 0; while(i < n && j < n) { if(starr[i] < endarr[j]) { // meeting started count++; i++; } else { // meeting ends count--; j++; } max = Math.max(count, max); // max no of rooms occupied right now } return max; }
0
0
Comments
Comments
On this page