 All right guys, so we're gonna do kth largest element of stream, which is basically the same thing as an array. They just wanted you to make Make a class. Okay, so what are we gonna start out with? We're gonna do the same thing that what I said before I'm gonna create a priority queue Let's see priority queue, which is a men heap When creating men heap In C++ priority queues are actually max heaps originally, but we're gonna make it into a min heap So I'm gonna make it this one make it into a men heap Okay, I think this is how it works. Let's see. Let's see this priority queue and C++. Yeah, that's how it works. Okay. Yeah Okay, then we need to create our size of our heap We'll start with a zero In the constructor, we'll do that later actually so in the add function if our men heaped size is Less is less than k which is our size is gonna be Yeah, okay, which is our size like here, I'm gonna do current K Current K and this is gonna current K is our size, right? Let's see originally. I'm gonna set it to Originally, it'll just be nothing but in our constructor will set current K equal to K. Yeah, okay, so if current K If our men heaps size is less than current K, then that means we'll just add the value to our men heat Men heap that push about you Otherwise we have to get the top most element. Remember men heat. We have to check the top most element men heap dot Top what am I doing? Okay, um, if the If the value is greater So basically if the value is Greater than our men heap the top of our men heap The top the first value of our heap men heap. We're going to remove the first value of our men heap So men heap dot pop That would remove the first value of our men heap then we're gonna Add add the value to our main heap. Okay Then after that what we're gonna do is in this case we're after and we're gonna remove we're gonna Return the first value of our main heap. Okay Now in the constructor after our setting our current K is equal to K. We're going to go through all the values in our array and We're going to call No, it's at I at each value Call add call the add function, which is gonna add each value and then no return. What are the kth largest is? Submit it and it got accepted right here a few seconds ago except it So this is basically how you do kth largest element in a stream I'm gonna show you another Not not another I'm going to do kth largest element in array now because it's basically the same thing and We'll do that in the next video because I mean I already explained how to do it. But yeah, that's how you do it Ray com scrap