Find K Pairs with Smallest Sums II Min Heap II Priority Queue II Merge k Sorted List II Leetcode 373

preview_player
Показать описание
In this video, I'll talk about how to solve Leetcode 373. Find K Pairs with Smallest Sums II Min Heap II Priority Queue II Merge k Sorted List

Let's Connect:

🛍️ Products I use in Videos: (✨ Marked for Mostly requested Products)

Resources you can try:

🎥Channel Playlists

About Channel:
We teach about how you can grow in life & educate about programming in Fun & Intuitional way.

About Me:
I am Aryan Mittal - a Software Engineer, 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
Рекомендации по теме
Комментарии
Автор

This one is Medium level but for Intuition Building is one of the best Problems 🙈


ARYANMITTAL
Автор

Bhai acche dance karte hoo aur explain bhi😁

adithyang
Автор

Thank you for the video! Your solution is better than the editorial solution on leetcode. I came to watch your video because I wanted to see if there is a better solution and yours is much better.

schan
Автор

Amazing explanation, i knew it was a min heap question but couldn't figure out how to apply it, brute force gave tle and mle

rohanchoudhary
Автор

Consider the test case:
nums1[1, 2, 3, 4] nums2[1, 10], k=2
for this the above approach gives incorrect answer right? As it considers only first k elements from the first list

KishoreKumar-tmig
Автор

From the first list you are taking only 'k' elements,
and Inside the while loop you are increasing the 'iterator' or 2nd list.
Soo the values after kth element in list 1 are never getting used🤔 How do you know that we have to neglect them?

arghyadas
Автор

Aryan's code matches to that of other peeps

soumyajitmishra
Автор

Hi bro, what can be the optimal code for given question?



There are N people who have already participated. The official has noted their weight and has ranked them. The problem is, he has fallen sick and there are still P people who are left to rank and participate. Considering this, you are expected to finish the process and provide the rank of the P people. Once the person is ranked, his weight is included in the category and the weight of the new person will have to consider this weight also to be ranked. To help you out, the new P people are organized in a queue in increasing order of their weights.

Input Format
The first line of input consists of two space-separated integers, N and P, number of people already ranked and number of people left to be ranked respectively.
The second line of input consists of N space-separated integers arranged in decreasing order, representing the weight of the N people.
The third line of input consists of P space-separated integers arranged in increasing order, representing the weight of the P people.

Constraints
1<= N, P <=10^5
0<= Ni, Pi <=10^9

Output Format
Print the rank of the Pi person at the given time in a separate line.

Sample TestCase 1
Input
5 3
120 100 100 90 60
40 40 80
Output
5
5
4

shwetanshusood
Автор

I just realized that this doesn't work for negative numbers -10 ^ 5 < 0 .
Correct me if wrong . Sorry maybe it will work not sure .

rimurutempest
Автор

striver ne padhaya hota to kabhi yeh video kholni na padti. Jhel raha hu jaise taise

leftover
Автор

Bhai tum kya code explainer ke chote bhai ho 😂 ?

googlePowerful