3181 & 3180 | BitSet Crash Course | DP | 3181. Maximum Total Reward Using Operations II & I

  Рет қаралды 6,611

Aryan Mittal

Aryan Mittal

Күн бұрын

In this video, I'll talk about how to solve Leetcode 3181. Maximum Total Reward Using Operations II | BitSet Tricks | 3180. Maximum Total Reward Using Operations I | DP
Bit Manipulation Crash Course - • BIT MANIPULATION Crash...
Let's Connect:
📱Discord (Join Community) : / discord
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / codewitharyanbhai
💻 Twitter - / aryan_mittal007
🤖 Github: github.com/aryan-0077
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✨
0:00 - Bakwas
1:00 - Problem Explanation & Intuition
5:10 - Brute Force & Hint of 0/1 Knapsack
7:30 - Figuring out Complexity of DP solution
9:47 - Coding DP Solution with Explanation
13:08 - Similar Problem for Sequence II (Leetcode 1981)
16:52 - What we have to do in Sequence II ultimately
19:40 - Understanding complexity of above Sequence II strategy
22:55 - BITSET Quick Course
30:56 - Using Bitsets in Sequence II for optimization
39:37 - Code Explanation of sequence II
43:56 - Optimizing above Code (Pruning)
47:54 - Code Explanation of Pruned Approach
50:25 - Bheek Continued :)
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Пікірлер: 43
@ARYANMITTAL
@ARYANMITTAL 21 күн бұрын
I know the video is wayy beyond 20mins(promised time), but pls try to jump on respective Timestamps for understanding 🥺 . And haan iss baar 45k paar ❤
@sahilkarwani9629
@sahilkarwani9629 21 күн бұрын
I think in First DP approach the ans should be divide by 2 before returning.
@zen-g-host
@zen-g-host 20 күн бұрын
Hi Aryan! Amazing explanation indeed. Would it be possible for you to share the PDFs of your explanation you used in the video. It would be really great to glance over after watching the video. Thanks.
@ayushmehta2323
@ayushmehta2323 20 күн бұрын
please provide with the pdfs especially for long videos
@dharmeshkumar3408
@dharmeshkumar3408 21 күн бұрын
Thanks brother ! I spent whole day trying to figure out the logic of Hard problem... but after watching this everything is clear.... video was long but necessary.
@fraserdab
@fraserdab 21 күн бұрын
Honestly was so lost when I saw bitset solutions because I've never heard of bitset, watching the video helped a lot
@ManishKumar-dk8hl
@ManishKumar-dk8hl 21 күн бұрын
isse solve krte hue aaj pehle recursion m TLE a gya tha then memoization pe MLE then tabulation krte krte mene haar maan li thi
@pabitrakb5291
@pabitrakb5291 21 күн бұрын
Gajab explanation ❤ Hats off to your hard work and patience
@ayush2060
@ayush2060 21 күн бұрын
One of the finest explanation I've seen . Bhaiya bhot maza ayaa
@jayantshukla9025
@jayantshukla9025 14 күн бұрын
Yaar maza aa gya. Lovely explanation.
@prathameshyadav2001
@prathameshyadav2001 21 күн бұрын
Good Explaination.Thanks for the timestamps.
@rushikeshkulkarni7758
@rushikeshkulkarni7758 21 күн бұрын
Nice Explanations, Thank you sir !!
@_u_ya-dw6vx
@_u_ya-dw6vx 16 күн бұрын
it was so good! thank you bhaiya!
@CodeCrusader702
@CodeCrusader702 16 күн бұрын
very nice bhaiyya.explanation give me the intuitions.
@ashoke8031
@ashoke8031 15 күн бұрын
Great content!
@suyashjadaun3279
@suyashjadaun3279 21 күн бұрын
Ho jayega 45K subscribers
@Abc-lr4bf
@Abc-lr4bf 20 күн бұрын
thanks good explanantion aryan
@ParthTagalpallewar
@ParthTagalpallewar 17 күн бұрын
@Aryan I wanted to share some feedback on your video. I noticed that there were a few instances where the same sentence was repeated multiple times. I believe the video could be even more engaging and concise without those repetitions. Just a suggestion for future videos to keep the content as clear and streamlined as possible. Thank you for your hard work!
@trishahalder9605
@trishahalder9605 21 күн бұрын
Great optimisation
@testeryes9376
@testeryes9376 21 күн бұрын
Good Stuff, Thanks
@iWontFakeIt
@iWontFakeIt 19 күн бұрын
the best! thank you
@ajayc815
@ajayc815 21 күн бұрын
waiting for this video !!!!!!!!
@23cash86
@23cash86 21 күн бұрын
Great video bro
@rajeshsingh-mv7zn
@rajeshsingh-mv7zn 19 күн бұрын
You're awesome.
@aniketburman2662
@aniketburman2662 21 күн бұрын
Why taking a vector dp(n+1) giving tle? can anyone explain?
@rajveersingh95
@rajveersingh95 18 күн бұрын
in java bitset class cannot be used with "bitwise and" operator. also the inbuilt "and" function stores the result of "and" to the first operand and returns void. Also there is no way to left shift except shifting each set bit left in a loop.
@rajveersingh95
@rajveersingh95 18 күн бұрын
Getting TLE with bitset. #justJAVAthings They should just rename it as class ShitSet at this point.
@vinaydesai8104
@vinaydesai8104 20 күн бұрын
Nice explanation
@chemicalenggnotes
@chemicalenggnotes 15 күн бұрын
thanks
@ajayprabhu465
@ajayprabhu465 20 күн бұрын
Long videos are needed, the problem is with ppls attention span, which is reduced to less than that of a goldfish due to scrolling reels.
@ajayc815
@ajayc815 21 күн бұрын
❣❣❣❣
@rajrajesh1669
@rajrajesh1669 7 күн бұрын
22:26 can anyone please give me the mathematical reasoning behind reducing the 10^5 (10^4+10^4), to 10^4 ?
@adarshsinghparihar7321
@adarshsinghparihar7321 20 күн бұрын
DP se nahi kar sakte kya ye problem i am trying to do with dp. 1st one is done by recursive dp int n; int solve(int i,int x,vector& v,vector& dp){ if(i==n) return x; if(dp[i][x]!=-1) return dp[i][x]; int nottake = solve(i+1,x,v,dp); int take = 0; if(x= 0 && x - v[i - 1] < v[i - 1]) { take = v[i - 1] + pre[x]; } cur[x] = max(take, nottake); } pre = cur; } return pre[0]; } it is showing wrong answer how to correct this please help me to solve this prolblem
@komalvaishnav5828
@komalvaishnav5828 15 күн бұрын
How can u take the reward sum value atlast will be the max of rewvalues in the above sum, before 9 mins
@top_g755
@top_g755 21 күн бұрын
Bro u said 35 k subs in beginning
@advaithmahendrakar
@advaithmahendrakar 14 күн бұрын
Any prerequisities for this video Except BIT MANIPULATION cause I have no knowledge on DP !! ?
@2amCoder
@2amCoder 10 күн бұрын
6:20 bro i moved on
@paras6079
@paras6079 21 күн бұрын
i was trying to do dp with binary search, because we require next Element to be greater than the previous one, i tried to do like this, jaise aapne ISS VIDEO mein bataya tha, bhaiya aap bata sakte ho ki iss question mein ye solution work kyo nahi kar raha. kzfaq.info/get/bejne/i-BinLGZz62rnWQ.htmlsi=Tg7B_P-OXmPaHGDT (edit) : int maxTotalReward(vector& nums) { // Remove duplicates and sort the nums vector sort(nums.begin(), nums.end()); nums.erase(unique(nums.begin(), nums.end()), nums.end()); int n = nums.size(); // Define the solve function with memoization function solve = [&](int t) -> int { if (t == 0) { return 0; } auto p = lower_bound(nums.begin(), nums.end(), t); if (p == nums.end()) { --p; } if (*p == t) { return t; } else if (*p > t) { if (p != nums.begin()) { --p; } else { return 0; } } int ans = 0; while (p >= nums.begin() && *p * 2 - 1 > ans) { ans = max(*p + solve(min(t - *p, *p - 1)), ans); if (p == nums.begin()) { break; } --p; } return ans; }; return solve(nums.back() * 2 - 1); } i found this binary search solution but not able to understand it, can anyone please tell why the call is from (nums.back() * 2 - 1); and not (nums.back() - 1); simply
@Mr.ChirayuFromVIT
@Mr.ChirayuFromVIT 20 күн бұрын
bhai koi aur color ki t shirt plz. Much love :)
@rutwikmore7462
@rutwikmore7462 21 күн бұрын
samjh nhi ata, question itna hard hai ya, ye banda hard bana ke samjhata hai ..😂
@user-bh9ts7db5r
@user-bh9ts7db5r 21 күн бұрын
Mujhe pata hai tumhe kyu nahi samajh aa raha, aisa isliye ho raha kyuki shayad tum hi gadhe ho
@rohitkumarpilania94
@rohitkumarpilania94 18 күн бұрын
You are always my last option to understand a problem, not because you are bad at teaching, rather it means no it's time that I need my best weapon against that question.
3174. Clear Digits | Simulation | Arrays | 2 Pointers
5:09
Aryan Mittal
Рет қаралды 1,1 М.
3 wheeler new bike fitting
00:19
Ruhul Shorts
Рет қаралды 52 МЛН
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 57 МЛН
Just try to use a cool gadget 😍
00:33
123 GO! SHORTS
Рет қаралды 85 МЛН
FOOLED THE GUARD🤢
00:54
INO
Рет қаралды 62 МЛН
The unfair way I got good at Leetcode
6:47
Dave Burji
Рет қаралды 385 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 277 М.
Returning with a win in Leetcode Biweekly 133!!!
17:05
Joshua Chen
Рет қаралды 2 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 205 М.
4 Steps To Solve Any Problem
14:04
The Math Sorcerer
Рет қаралды 477 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Most Common Concepts for Coding Interviews
6:08
NeetCode
Рет қаралды 281 М.
Starting Competitive Programming - Steps and Mistakes
9:55
William Lin
Рет қаралды 1,4 МЛН
3 wheeler new bike fitting
00:19
Ruhul Shorts
Рет қаралды 52 МЛН