3201, 3202. Find the Maximum Length of Valid Subsequence II | | Math | DP | LIS Similar
Vložit
- čas přidán 27. 07. 2024
- In this video, I'll talk about how to solve Leetcode 3202. Find the Maximum Length of Valid Subsequence II | 3201. Find the Maximum Length of Valid Subsequence I | Math | DP | LIS Similar
LIS Concept - • Find the Longest Valid...
Code for top down code (same as what we discussed in video) - leetcode.com/problems/find-th...
[and yeah, as we are having i, j, & prevRem] - thus complexity will be O(n*n*k)
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
2:35 - Building up Intuition for Leetcode 3201
7:22 - LC 3201 Explanation
11:22 - Code Explanation
13:16 - Another way to solve LC 3201 (curRem, prevRem, curRem) form
20:16 - LC 3202 Explanation, Code & Dry Run Explample
24:34 - LC 3202 Top-Down approach thinking (Code in Description)
31:06 - Space Optimised O(k) Solution
37:10 - Like thok dena
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
i also tried the recursive memoize approach TC-> O(k^2 *n) and i got MLE.
not understood
This solution is incredible! good work!
What I was thinking in first at the time of contest is using recursive with memoization and it is good to go and solved both Q2 & Q3 but when I used memoization it gives memory limit exceed error i both the cases and My submission is left with just last 10 cases in both the Questions and due to that I was stuck on these Questions in my whole leetcode contest and that actually ruined/fucked up my mind totally. My question is that to you Aryan that how we should think out like these approaches at the time of contest because in my mind apart from memoization no other approached come .
He is been doing this for many years now. It's all about consistent practice and evolving yourself with different approaches
@@sanketchugh294 Thank you I didn't know this before.
this is a complex explanation usually if a tutor explains in a complex way i dry run by myself to understand what he is saying but in this video i have to rewatch some of the section again and again to understand
true
i cant understand 🥲
even i can't
great video Aryan
Bhai 1st wali bhi thodi tricky thi
aryan cant understand this, idk why, first the first time feeling very bad
Aryan Mittal read it positively please => you are under misconception that you are simplifying problem, but you are actually overexplaining everything which is actually harder to understand than it actually should.
My suggestion => Try to focus on what i said and try to see that in your videos. You can explain to only those actually don't need explanations, that's where comes tricky part that if someone already know intution then he will think that you are explaining very good, and if he doesn't know approach then he will think that he himself need to improve because of your over justifying things, rather you should just simplify problem to everyone like it force them to think that actually problem was too easy, that's where youtubers like Striver, Love babbar, CodeWithHarry , chai aur code , etc, shines and you do not even come close to them.
true bro
12:08 don't explain code we are not machines, explain approach with dry runs, and please take it positively and you will shine on youtube in the world of coding.
🫡
My memoization java code runs ->
class Solution {
int dp[][];
int kk;
public int maximumLength(int[] nums, int k) {
int n = nums.length;
kk = k;
dp = new int[n+1][k+1];
for (int[] d1 : dp) {
Arrays.fill(d1, -1);
}
int ans = 0;
for(int i=n-1; i>0; i--){
for(int j=i-1; j>-1; j--){
ans = Math.max(ans , 2 + solve(nums , j , (nums[j] + nums[i]) % kk)); //finding first two elements.
}
}
return ans;
}
public int solve(int[] nums, int pre, int mod) {
if (pre == -1) return 0;
if (dp[pre][mod] != -1) return dp[pre][mod];
int ans = 0;
for (int i = pre-1; i >= 0; i--) {
if ((nums[i] + nums[pre]) % kk == mod) {
ans = Math.max(ans, 1 + solve(nums, i, mod));
break;
}
}
dp[pre][mod] = ans;
return ans;
}
}
suggestion if possible remove top down section as it is so much confusing rest other is awesome
completely disagree, it's for the intuition
Today's problem to upload karo jaldi
Remove Graph edges
check their community post
@@Jazzimus
I checked it already in morning but unfortunately I thought it is only hint so I didn't click on it and I couldn't see the video link.
Thanks .
Bhai hindi me bol liya kro nhi dekhra koi bahr ka tume vo discussion section se samajh kete ha
true bhai...
Bro please accept my connection request !!
optimization of 3202 freezed my brain
true
First why r u elaborating all the stuffs which is very much irritating secondly u r teaching to graduate student not a kg school child
Not everyone watching is a graduate student
dude if see his hard problem explanation he make them look damn easy by this style and skip the simple part i usually do that and watch at 1.5-1.75.
Bro please accept my connection request !!
Bro full name to bata dete🥲, how will i search just Shashank ❤️