2402. Meeting Rooms III | Sorting | Heap(Priority Queue) | Hard 🥶

  Рет қаралды 3,864

Aryan Mittal

Aryan Mittal

4 ай бұрын

In this video, I'll talk about how to solve Leetcode 2402. Meeting Rooms III | Sorting | Heap(Priority Queue) | Hard 🥶
Checkout DSA-169 Series: • Aryan DSA-169 Series |...
100Days 100k Placements: • 100 Days 100K Placement
Let's Connect:
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / ez.pz.dsa
📱Telegram : t.me/aryan_mittal_group
🤖 Github: github.com/aryan-0077
About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
✨ Timelines✨
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Пікірлер: 17
@dharmrajmagdum9093
@dharmrajmagdum9093 4 ай бұрын
at 30:27 ha ha ha🤣😂🤣😂 , maksad nahi bhulna hai, ie. return id of room with max meeting held. by the way , great explanation as all ways.
@fraserdab
@fraserdab 4 ай бұрын
This whole week is heaps man
@onlysparsh
@onlysparsh 4 ай бұрын
maksad nahi bhulna hei
@prakashnandan7337
@prakashnandan7337 4 ай бұрын
🤣😂
@fraserdab
@fraserdab 4 ай бұрын
I feel like its better to use an array instead of a map or unordered map and find max in ond way or another then return index of first max element
@mayankrohilla4105
@mayankrohilla4105 4 ай бұрын
Appreciate the explanation very much! just a little suggestion: try to make smaller videos
@ankushmitra6504
@ankushmitra6504 4 ай бұрын
Did you use any extensions for knowing company tag in leetcode?
@saunaknandi1814
@saunaknandi1814 4 ай бұрын
Bro he have subscription
@yuvrajveerdhawan8196
@yuvrajveerdhawan8196 4 ай бұрын
bro please solve the today weekly contest also
@harshal8781
@harshal8781 4 ай бұрын
Meeting rooms l,ll solve karne ke liye premium lagega 😢
@agambedi4142
@agambedi4142 4 ай бұрын
bro a small request can you please provide JAVA code too? I try firstly by myself but questions like this is very tricky and need some overview of a solution, please provide java code too.
@saunaknandi1814
@saunaknandi1814 4 ай бұрын
Bro why are you hiding those company names?
@harshal8781
@harshal8781 4 ай бұрын
publicly aise show karege to leetcode 🤐
@akashspace4977
@akashspace4977 4 ай бұрын
I have written the same code in JAVA, but all the test cases are not passing. Can anyone help? class Pair { int endTime; int id; Pair(int endTime, int id) { this.endTime = endTime; this.id = id; } } class Solution { public int mostBooked(int n, int[][] meetings) { Arrays.sort(meetings, new Comparator() { @Override public int compare(int[] e1, int[] e2) { if (e1[0] != e2[0]) { if (e1[0] < e2[0]) { return -1; } else { return 1; } } else { if (e1[1] < e2[1]) { return -1; } else { return 1; } } } }); TreeMap booked = new TreeMap(); PriorityQueue free = new PriorityQueue(); Comparator c = new Comparator() { @Override public int compare(Pair p1, Pair p2) { if (p1.endTime == p2.endTime) { if (p1.id < p2.id) { return -1; } else { return 1; } } else { if (p1.endTime < p2.endTime) { return -1; } else { return 1; } } } }; PriorityQueue full = new PriorityQueue(c); for (int i = 0; i < n; i++) { free.add(i); } for (int i = 0; i < meetings.length; i++) { int start = meetings[i][0], end = meetings[i][1]; // If there is some room which was occupied but now is free while (!full.isEmpty() && full.peek().endTime maxMeetings) { maxRoomId = room; maxMeetings = booked.get(room); } } return maxRoomId; } }
@divyanksrivastava7229
@divyanksrivastava7229 4 ай бұрын
same
@divyanksrivastava7229
@divyanksrivastava7229 4 ай бұрын
hey, I tried to take data type as long and passes all test case give it a try class Solution { public int mostBooked(int n, int[][] meetings) { long[] freq = new long[n]; // Change to long array PriorityQueue free = new PriorityQueue(); PriorityQueue pq = new PriorityQueue(Comparator.comparingLong((ArrayList a) -> a.get(1)).thenComparingLong(a -> a.get(0))); for (int i = 0; i < n; i++) { free.add(i); } Arrays.sort(meetings, Comparator.comparingInt(a -> a[0])); for (int[] a : meetings) { int start = a[0]; int end = a[1]; while (!pq.isEmpty() && pq.peek().get(1) size) { size = freq[i]; ans = i; } } return ans; } }
Meeting Rooms III - Leetcode 2402 - Python
16:16
NeetCodeIO
Рет қаралды 19 М.
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 33 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 39 МЛН
Part 1/3: Introduction to Kruskal Wallis Test
16:29
Afzalina Azmee
Рет қаралды 3
2.6.3 Heap - Heap Sort - Heapify - Priority Queues
51:08
Abdul Bari
Рет қаралды 2 МЛН
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 772 М.
1791. Find Center of Star Graph | Indegree - Outdegree | Microsoft
6:02