3218 & 3219. Minimum Cost for Cutting Cake II & I | Greedy | Sorting

  Рет қаралды 4,488

Aryan Mittal

Aryan Mittal

Күн бұрын

In this video, I'll talk about how to solve Leetcode 3219. Minimum Cost for Cutting Cake II | 3218. Minimum Cost for Cutting Cake I | Greedy | Sorting
Let's Connect:
📱Discord (Join Community) : / discord
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / codewitharyanbhai
💻 Twitter - / aryan_mittal007
🤖 Github: github.com/ary...
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

Пікірлер: 26
@ARYANMITTAL
@ARYANMITTAL 3 ай бұрын
Do you guys want for Problem 1 & 2 also? do let me know❤
@RajatGore-bl6lv
@RajatGore-bl6lv 3 ай бұрын
Thank you , 1 & 2 already done
@TON-108
@TON-108 3 ай бұрын
1st one is too easy, you can go with 2nd (this is also basic linked list problem but still)
@sanasainath7758
@sanasainath7758 3 ай бұрын
No
@tushar404
@tushar404 3 ай бұрын
Naa, Too easy Maybe for 2nd if possible without using set??
@mohammedaltaf4316
@mohammedaltaf4316 3 ай бұрын
No 1 and 2nd done too easy
@subhankarkanrar9494
@subhankarkanrar9494 3 ай бұрын
Very good explanation Aryan ☺️
@arjunreddynarala
@arjunreddynarala 3 ай бұрын
Amazing logic bro , love your consistency❤
@vishalmishra1937
@vishalmishra1937 3 ай бұрын
superb explanatiion. i stuck on intuition on new problems . any suggestion u can give i can work upon it.
@10minutes_cs
@10minutes_cs 3 ай бұрын
4:31 mac cam is funny sometimes ..
@ARYANMITTAL
@ARYANMITTAL 3 ай бұрын
Truee 😂
@harshalgarg1676
@harshalgarg1676 2 ай бұрын
thanks bro
@rishantrana3953
@rishantrana3953 3 ай бұрын
Can you also try to cover Atcoder contest?
@AzeemKhan-sn3yi
@AzeemKhan-sn3yi 3 ай бұрын
luv u bhai!!
@nptel1punith929
@nptel1punith929 3 ай бұрын
is it m*n cuts required?
@immrhrr
@immrhrr 3 ай бұрын
Use count sort instead of inbuilt sort in cpp to get it done in o(n) instead of nlogn 😅
@immrhrr
@immrhrr 3 ай бұрын
Because range is given from 1 to 1000 only😅
@anubhavgupta5184
@anubhavgupta5184 3 ай бұрын
can you prove your solution ?
@AJK-a2j00k4
@AJK-a2j00k4 2 ай бұрын
bro it's greedy solution, you can't prove it.. just intuition!
@anubhavgupta5184
@anubhavgupta5184 2 ай бұрын
@@AJK-a2j00k4 How did you prove the correctness of your greedy solution ? :)
@AJK-a2j00k4
@AJK-a2j00k4 2 ай бұрын
@@anubhavgupta5184 maybe make some testcases and try it out.. I am not a pro so fully not sure :)
@shashankmaurya-w7d
@shashankmaurya-w7d 3 ай бұрын
long long minimumCost(int m, int n, vector& h, vector& v) { long long res = 0, hcut = 1, vcut = 1; sort(h.rbegin(), h.rend()); sort(v.rbegin(), v.rend()); int i = h.size() - 1, j = v.size() - 1; while(i >= 0 && j >= 0){ if(h[i] > v[j]){ res += (h[i]*vcut); hcut++; i--; }else{ res += (v[j] * hcut); vcut++; j--; } } while(i >= 0){ res += (h[i]*vcut); i--; } while(j >= 0){ res += (v[j] * hcut); j--; } return res; } can someone find the bug in my code.
@pankajsingh6451
@pankajsingh6451 3 ай бұрын
i think you are sorting in descending order bro , modify it to:- sort(h.begin(), h.end()); sort(v.begin(), v.end()); good luck
@rtadwq...------...----.
@rtadwq...------...----. Ай бұрын
Why the condition is "if (h[i] > v[i])" Not "if (vcut*h[i] > hcut*v[i])"
@aditya205
@aditya205 3 ай бұрын
thanks bro
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 25 МЛН
My Daughter's Dumplings Are Filled With Coins #funny #cute #comedy
00:18
Funny daughter's daily life
Рет қаралды 31 МЛН
Who’s the Real Dad Doll Squid? Can You Guess in 60 Seconds? | Roblox 3D
00:34
Жадные алгоритмы
11:10
про АйТи | IT Pro
Рет қаралды 7 М.
Viral Video of a Man's Crazy Job Interview
16:02
Darryl Vega TV
Рет қаралды 1,4 МЛН
1110. Delete Nodes And Return Forest | DFS | Tree
12:33
Aryan Mittal
Рет қаралды 4,2 М.
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Рет қаралды 247 М.
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 25 МЛН