330. Patching Array | Greedy | Array | Math | Why not Bitset Trick
ฝัง
- เผยแพร่เมื่อ 8 ก.ย. 2024
- In this video, I'll talk about how 330. Patching Array | Greedy | Array | Math | Why not Bitset Trick
Bitset Crash Course - • 3181 & 3180 | BitSet C...
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
How to balance College & CP - th-cam.com/video/79rxV2d86ww/w-d-xo.html
You and Neetcode are the only people I understand
Good thing that this guy uploads daily, solely responsible for my streak
Aryan Bhai Aaj pehli baar leetcode contest mei 4 problems solve kiye, your segment tree video is really great, thanks a lot
can you explain 3 problem i tried with class Solution {
public:
bool possible(int p,int check)
{
if(p==check-1 || p==check+1 || p==check+2 || p==check-2)
{
return false;
}
return true;
}
long long maximumTotalDamage(vector& power) {
sort(power.begin(), power.end());
int maxValue = *max_element(power.begin(), power.end());
long long pow=maxValue+2;
vectordp(maxValue + 4, 0);
for(int i=1;i=0;j--)
{
if (possible(power[i-1], j)) {
dp[j]= max(dp[j],power[i-1] + dp[power[i-1]]);
}
}
}
return dp[pow];
}
}; with this it was giving tle
THank you! Your explanation allows to grow analytical skills and setup the way of thinking about the problem. I also discovered that we can reach any `n` if the `prefixSum` of existing numbers more then `n`, but I couldn't code the solution :(
prefix sum find's us subarray sum? but here we can get through any possible combination isn't it?
Superb explanation!! Thank you so much Aryan! 👍
Thank you Aryan ❤.
Some simple observation that number such as ((1
beautiful explanation!
Great Explanation brother !!
Awesome explanation man !
WHY GREEDY WORKS
_TO PROVE_
----> If the greedy algorithm needs to patch k numbers to cover [1,n] it is impossible to patch less than k numbers to do the same.
_Proof by contradiction_
let's say for a given value of n and an array nums
GREEDY gives x1 < x2 < x3 < ... < xk patches (total K patches)
ANOTHER SOLUTION gives y1
Can you write a bit of a big text
weekly contest problem ??
Coming sir🫡❤️
Let him breath haha.
@@PalakKalsi he is expert ,so he need to be quick😅
When we add 2 then we can make 3. Now 1 and 3 van make 4 so why you add 4 here
Great explanation sir !! Saluting your efforts even on Sunday morning !!🫡🫡🫡
bhaiya dimag kharab hogya ye question samajhte samajhte
ab pehle iska code likhunga, fir subah uth kr dry rrun krunga 2-3 baar
🫡🫡🫡
bro your english prickles my ear please work on it or speak in hindi you are so repeatitive man !!! just speak to the point and move on