Leetcode | Biweekly Contest 132 | 3176 | 3177 | Find the Maximum Length of a Good Subsequence II.
Вставка
- Опубліковано 8 сер 2024
- Biweekly Contest 132 | C | D | 3176 | 3177 | Find the Maximum Length of a Good Subsequence II | Editorial.
C Recursive DP Solution : leetcode.com/contest/biweekly...
D Iterative DP Solution : leetcode.com/submissions/deta...
#leetcode
#3176
#3177
#BiweeklyContest
#132
#dp
#segmenttree
#lazypropogation
#hindisolution
#ProgrammingTutorial
#AlgorithmExplanation
#StringManipulation
#codinginhindi
#dynamicprogramming
#CodeChefContest
#problemsolving
#BinaryStrings
#programminginhindi
#CompetitiveProgrammingTutorial
#AlgorithmExplanationInHindi
#StringManipulationTutorial
#codingtutorial
#HindiCodingTutorial
#CodeChefContest
#problemsolving
#BinaryStrings
#programminginhindi
#CompetitiveProgrammingTutorial
#AlgorithmExplanationInHindi
#StringManipulationTutorial
#codingtutorial
#HindiCodingTutorial
#algorithmanalysis
#programminglogic
#problemsolvingtechniques
#StringManipulationTechniques
#codeexplanation
#HindiProgrammingTutorial
#codingtips
#programmingeducation
#OnlineProgrammingContest
#ProgrammingSkills
#computersciencetutorial
00:00 Problem Statement
01:36 Solution
19:31 Code Explanation.
Bhai you are good problem solver . Apka explanation dekhne ke baad sab clear ho jata . You deserve millions subscriber.
Thankyou ❤️
Great vid, awesome explanation
Thankyou
Lovely explanation
Thankyou
I appreciate your explanation 🙂...you explained it from scratch..taking an example made me to understand easily.. thanks for vid 😁
Thankyou
Great explanation.There is no need of using a priority queue ,we can just use a variable for max value to the right and keep updating the variable.also we can use unordered map instead of ordered map.
Thankyou.
Right, it's upon you to optimize as much as possible.
Thanks for uploading the solution
Thankyou
Your explanation is really good and clear; although I was about skip the video because of audio quality. Hopefully we will get clear audio from the next solution.
Thankyou.
@@pretestpassed157 I have a question. What would be the codeforce difficulty rating of this problem?
I dont do codeforce; although you have mentioned D; I guess there multiple div in codeforce contest. Im confused..
According to me, It will be around 1700 rating.
best explanation bro!!
Thankyou
great explanation
Thankyou
Great Explanation!! But I have a small doubt in the operation 1, suppose we are finding dp[k][i] and we got dp[k-1][i+2] as maximum among (dp[k-1][i+1], dp[k-1][i+2], ....), it is very well possible that nums[i+2] == nums[i], then we shouldn't use an operation right, Is it working because we are asked to find for atmost k operations and not exactly k operations??
Thankyou.
Yes we have to use atmost k Operation, so let's suppose if nums[i] == nums[i+2].
So we are just asking for the maximum from both operations. And those two cases are going to handle it.
Thanks for Sharing
Thankyou
Sir OA m help krdijiye pls
sab log subscribe karo please taki agge bhi aise solutions mil sakhe🙏🙏🙏
Thankyou ❤️
@@pretestpassed157 bhahiya mujhe batao dp kidar se kru? Har contest mai 3 Rd 4th dp kar he aa rah
Just start practicing, easy level questions of dp from leetcode if you get confident from easy one switch to medium level and then hard. And also try to remember it's pattern so that if next time you tackle the same kind of problem then you can apply its logic to that problem.
Also just try to spend some time on the problem and if still you didn't get any logic then just see its minor hint rather than seeing the solution directly and then try to solve, if u are able to solve then it's ok otherwise you can see the solution after spending some time.
Just follow it for a few weeks, it will improve your dp.
But try to practice as many different dp problems as you can.
When you get some confidence, also start practicing from Cses DP problem set because there you will find all dp variant problems.
@@pretestpassed157 thank you♥️
So the conclusion is I have to practice more and more
Aapki awaz ladki jaisi hai 😅
Oooo Bhai ..
Chlo prank call me kaam dega 🥹
don't know why this solution fails. 506/543 testcases are passing.
This testcase is failing
nums = [49,50,50,48,48]
k = 1
Output
3
Expected
4
It would be appreciating if someone helps me out
Code
class Solution {
int[][][] dp;
public int maximumLength(int[] nums, int k) {
dp = new int[nums.length][nums.length][26];
for(int[][] arr : dp){
for(int[] subarr : arr){
Arrays.fill(subarr, -1);
}
}
return maxl(nums, 0, 0, -1, k);
}
public int maxl(int[] nums, int curri, int len, int prei, int k){
if(curri == nums.length){
return len;
}
if(prei == -1){
int take = maxl(nums, curri + 1, len + 1, curri, k);
int nontake = maxl(nums, curri + 1, len, -1, k);
return Math.max(take, nontake);
}
if(dp[curri][prei][k] != -1) return dp[curri][prei][k];
int take = len;
int nontake = len;
if(nums[curri] == nums[prei]){
take = maxl(nums, curri + 1, len + 1, curri, k);
dp[curri][prei][k] = take;
return take;
}
else{
if(k - 1 >= 0) take = maxl(nums, curri + 1, len + 1, curri, k - 1);
nontake = maxl(nums, curri + 1, len, prei, k);
dp[curri][prei][k] = Math.max(take, nontake);
return Math.max(take, nontake);
}
}
}
if i dont take this len parameter and add 1 while take condition, then it is passing. Pls help me someone i am frustrated now