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.

КОМЕНТАРІ • 34

  • @shubhamrai8673
    @shubhamrai8673 2 місяці тому +4

    Bhai you are good problem solver . Apka explanation dekhne ke baad sab clear ho jata . You deserve millions subscriber.

  • @techyguy7776
    @techyguy7776 2 місяці тому +2

    Great vid, awesome explanation

  • @ashish3487
    @ashish3487 Місяць тому +1

    Lovely explanation

  • @manideep4259
    @manideep4259 Місяць тому +1

    I appreciate your explanation 🙂...you explained it from scratch..taking an example made me to understand easily.. thanks for vid 😁

  • @kuldeepmeena9073
    @kuldeepmeena9073 Місяць тому +1

    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.

    • @pretestpassed157
      @pretestpassed157  Місяць тому

      Thankyou.
      Right, it's upon you to optimize as much as possible.

  • @gyanikumari4973
    @gyanikumari4973 2 місяці тому +1

    Thanks for uploading the solution

  • @Syed_Shifat
    @Syed_Shifat 2 місяці тому +1

    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.

    • @pretestpassed157
      @pretestpassed157  2 місяці тому

      Thankyou.

    • @Syed_Shifat
      @Syed_Shifat 2 місяці тому +1

      @@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..

    • @pretestpassed157
      @pretestpassed157  2 місяці тому

      According to me, It will be around 1700 rating.

  • @anonymous10906
    @anonymous10906 2 місяці тому +1

    best explanation bro!!

  • @mjmusic65
    @mjmusic65 2 місяці тому +1

    great explanation

  • @AvanagantiAkshathreddy
    @AvanagantiAkshathreddy 2 місяці тому +1

    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??

    • @pretestpassed157
      @pretestpassed157  2 місяці тому

      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.

  • @reactcode9148
    @reactcode9148 2 місяці тому +1

    Thanks for Sharing

  • @Munna_bhiyaa
    @Munna_bhiyaa 2 місяці тому

    Sir OA m help krdijiye pls

  • @ronakkriplani1838
    @ronakkriplani1838 2 місяці тому +2

    sab log subscribe karo please taki agge bhi aise solutions mil sakhe🙏🙏🙏

    • @pretestpassed157
      @pretestpassed157  2 місяці тому +1

      Thankyou ❤️

    • @ronakkriplani1838
      @ronakkriplani1838 2 місяці тому +2

      @@pretestpassed157 bhahiya mujhe batao dp kidar se kru? Har contest mai 3 Rd 4th dp kar he aa rah

    • @pretestpassed157
      @pretestpassed157  2 місяці тому +1

      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.

    • @ronakkriplani1838
      @ronakkriplani1838 2 місяці тому +2

      @@pretestpassed157 thank you♥️
      So the conclusion is I have to practice more and more

  • @feelyourbeat7820
    @feelyourbeat7820 2 місяці тому

    Aapki awaz ladki jaisi hai 😅

  • @RohanPatil-gz6un
    @RohanPatil-gz6un 2 місяці тому

    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