Leetcode Weekly 388 | 3077 Maximum Strength of K Disjoint Subsets | 3D DP | Guardian @Leetcode
In weekly 388 contest, we had an interesting 3D DP Problem: leetcode.com/problems/maximum...
This problem uses Dynamic Programming in an interesting fashion.
Connect on Linkedin: www.linkedin.com/in/bharat-kh...
Connect on Insta: / bharatkhanna1995
Problem 4: You have option at each index. If a subarray is being continued from past, take this element into subarray or close this subarray at previous point. If no subarray is coming from past, start a new one here or ignore this element. Use recursion and memoize it.
Link: ideone.com/MyAvjg
00:00 - 03:14 Problem Description
03:15-05:29 Why Greedy Fails?
05:30-10:10 Options and Recursion
10:11-13:30 State and Recurrence Relation
13:31-22:56 Code + Base Cases Explained
Пікірлер: 13
Wow great explanation
@CodingwithBharat
3 ай бұрын
Thanks Akash
Sir please make a video on Kadane's algorithm.You explain things beautifully
@CodingwithBharat
3 ай бұрын
Yes that is the topic of this week ✌️
nicely explained bro, btw can you help me understand how we can do max sum subarray using dp like this instead of standard Kadane, want to develop my understanding around that
@CodingwithBharat
3 ай бұрын
Remove x from the logic. 2D DP which is 2*n.
@CodingwithBharat
3 ай бұрын
Will take Kadane as topic of the week anyways. So we will cover multiple problems on this algo.
Bhaiya please make videos on mcm questions
@CodingwithBharat
3 ай бұрын
Will plan them!
@CodingwithBharat
3 ай бұрын
Each video will be an hour long though 😂 It is a difficult concept
@piyushsrivastava5883
3 ай бұрын
@@CodingwithBharat thank u
Q : In this why you haven't checked for (a == LLONG_MAX) condition, you only checked for (b == LLONG_MAX) condition, Please Explain
@CodingwithBharat
3 ай бұрын
Good question! Even if a is llong_min, it will go to max(a,b) and we will be fine. The thing with b is if you see we are adding something to b. If b is llong_min and we add some more to it, it might become some finite value and we will get it back in max. We want to keep impossible case as llong_min only. Adding something to it will give some other value which is not llong_min