Maximum Subsequence Score | Intuition | AMAZON | Leetcode-2542 | Explanation ➕ Live Coding

preview_player
Показать описание
Hi everyone, this is the 8th video of our Heap Playlist.
In this video we will try to solve a very good Problem on the heap “Maximum Subsequence Score”.
We will do live coding after explanation and see if we are able to pass all the test cases.

Problem Name : Maximum Subsequence Score
Company Tags : AMAZON

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Рекомендации по теме
Комментарии
Автор

deekho bhai log mere dimag main pheli cheez dp aayi aur tle aaya without second thought mai codestory withmik ke paas aaya 40 min ka video dekha mai samajh gya mik will explain the recurrsion aur he did
i think aagar sayad mik 2 saal phele start krta content dalna i would have been more better
there is saying that "you get the right teacher only when you have worked enough hard to find one"
and every subscriber of mik has worked hard to get him

satyamkumaryadav
Автор

Also one important thing, in Recursion approach, we don't need to use priority queue. Instead, you can keep updating the min element during recursion only. Please find the code below :

//Recursion + Memo + Without min-heap
class Solution {
public:
int K;
int n;
unordered_map<string, int> mp;

long long solve(vector<int>& nums1, vector<int>& nums2, int sum, int min_el, int i, int count) {
if(count == K) {
return sum * min_el;
}
if(i >= n) {
return 0;
}

string key = to_string(sum) + "_" + to_string(min_el) + "_" + to_string(i) + "_" + to_string(count);
if(mp.find(key) != mp.end())
return mp[key];

int min_now = min(min_el, nums2[i]);

long take_i = solve(nums1, nums2, sum + nums1[i], min_now, i+1, count+1);

long not_take_i = solve(nums1, nums2, sum, min_el, i+1, count);

return mp[key] = max(take_i, not_take_i);
}

long long maxScore(vector<int>& nums1, vector<int>& nums2, int k) {
K = k;
n = nums1.size();
mp.clear();

return solve(nums1, nums2, 0, INT_MAX, 0, 0);
}
};

codestorywithMIK
Автор

Long video - Must Watch of this channel 😁.
This guy is simply a LEGEND. explained even minute details that I couldn't get from best channels on Youtube as well as neither from Leetcode official solution

wearevacationuncoverers
Автор

Your videos are the proof that you are a true programming expert😁😍. Thank you for sharing your expertise with us and helping us improve our skills.😊

MyCodingDiary
Автор

Bhai aap god ho
saari playlists kamal ki explanation top notch

berntalz
Автор

The style of approaching every question, narration, and representation. Everything is so perfect, one of the best channels I have ever found for learning DSA! I have learned a lot from your videos, wish you keep growing!

HarshSharma-zzdi
Автор

You are the best teacher on youtube buddy

pradumandhyani
Автор

Finest explanation for this problem in the entire YouTube

thekindspill
Автор

programming feels addictive with you sir ! your explanations really motivates to learn more and more about coding .thank you so much .

nezukochan
Автор

Commenting for better reach!! Keep going!

tharunkumar
Автор

One is best explained. Becomes top in dsa

dayashankarlakhotia
Автор

i appreciate your narration style for this question bro.... EXPLAINED VERY WELL! ❤❤

ashutoshpal
Автор

G.O.A.T / L.E.G.E.N.D ❣
I stopped at 31:13 and coded it up with the story
I also thought of DP first.
couldn't come up with 2nd approach (optimal) on my own.

souravjoshi
Автор

The only Channel who goes to depth and even minute details

AlishaKhan-wwio
Автор

If I saw this guys video then my search is over that's all it's not a easy question at all but this guy made it easy for you ❤❤

akshanshsharma
Автор

It's been a while I'm watching your videos to learn the logic from the very basic. Your explanation is really good. Keep the Hard work on .

athravmehta
Автор

learn't something new Thank You...

ManojKrVerma-vwdx
Автор

Thanks for such a crystal clear intuition

raisanjeeb
Автор

I was genuinely waiting for your video because I knew you'd definitely start from the basics(i.e., recursion). P.S.:- I went through a couple of other videos in the afternoon. So now, I can assure you that This is the best explanation!!!
Keep it up & Thank you so much.

gaaanedilse
Автор

bro, you're really good in explaination, loads of love to you bro, I did it with recursion earlier to your video, it failed like you said. I waited for your video for good aproach, really awesome, Thank You, I wiil surely recomend your channel, with new coders

supremeravi
welcome to shbcf.ru