Palindrome Partitioning with Minimum Cuts Dynamic Programming | Minimum Palindromic Cuts

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
    NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. Here you will learn about Minimum Palindromic Cut in Dynamic Programming. In this question:
    1. You are given a string.
    2. You have to find the minimum number of cuts required to convert the given string into palindromic partitions.
    3. Partitioning of the string is a palindromic partitioning if every substring of the partition is a palindrome.
    To attempt and submit this question, click here: www.pepcoding....
    For a better experience and more exercises, VISIT: www.pepcoding....
    #dynamicprogramming #palindrome #leetcode
    Have a look at our result: www.pepcoding....
    Follow us on our FB page: / pepcoding
    Follow us on Instagram: / pepcoding
    Follow us on LinkedIn: / pepcoding-education

КОМЕНТАРІ • 152

  • @baggiokillme
    @baggiokillme 3 роки тому +46

    Thank you for the video, it feels like aap actually interested ho ki viewer concepts ko samjhe. That is a very rare quality with such videos.

    • @Pepcoding
      @Pepcoding  3 роки тому +12

      I am glad. Keep learning. Keep supporting. Your kind words are the kind of motivation that truly help me in making more and more content. Especially, these days, not everybody is generous with motivating anybody either. It means a lot😊

  • @gaunikasrivastava7851
    @gaunikasrivastava7851 2 роки тому +4

    After facing disappointment from the videos of other channels, this video proved to be a saviour for me, or otherwise I wouldn't have got the solution to this problem. Thanks a lot!!

  • @vsinghal85
    @vsinghal85 2 роки тому +8

    It's a treat to watch your content Sumeet bhaiya. specially DP. The way you don't just tell the solution but also hidden why's and sought of entire research each and every question is really helpful for me and sure for other people as well. I am sure this content will really be helpful in creating epic developers and founders in India, I have been your student in classroom and always see same dedication and intent in youtube videos, as you have while teaching in classroom, perhaps even more. You really inspire me to put in same dedication into my work as you do. Thanks Bhaiya :)

    • @Pepcoding
      @Pepcoding  2 роки тому +2

      Thanks a ton ! For more content like this please visit nados.pepcoding.com

  • @shravyarajuri9114
    @shravyarajuri9114 2 роки тому +3

    You just make every problem look so simple with your detailed explanation. Great efforts!!

  • @rishabhshukla5199
    @rishabhshukla5199 2 роки тому +1

    Earlier I was like it is a lengthy video but after I started don't know when time passed. Thanky you Sumit sir for such high quality and engaging content.

  • @NiteshKumar-do4en
    @NiteshKumar-do4en 2 роки тому +2

    sir on youtube only your's video give clear understanding for dsa questions mostly the backtracking and dynamic programming questions

    • @Pepcoding
      @Pepcoding  2 роки тому +1

      Thank you Nitesh :) To watch more content like this with a better user experience visit nados.pepcoding.com

  • @siddharthkothari9651
    @siddharthkothari9651 3 роки тому +10

    THANK YOU SO MUCH FOR THIS, was literally on the verge of going crazy because the n³ solution kept throwing TLE, until I found this vid, great explanation, thank you.

    • @Pepcoding
      @Pepcoding  3 роки тому +1

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      ua-cam.com/users/Pepcodingabout?view_as=subscriber

  • @sameer1571
    @sameer1571 3 роки тому +1

    Sir hats off hai aapko. itna patience se padhana mjaak nahi hai. No words to explain right now . Thank you sir

    • @Pepcoding
      @Pepcoding  3 роки тому +1

      If you like my efforts, I request a review
      g.page/Pepcoding/review?rc

    • @sameer1571
      @sameer1571 3 роки тому

      @@Pepcoding done sir

  • @ayushupadhyaya7656
    @ayushupadhyaya7656 3 роки тому +1

    It was such a breeze to understand each and every concept in this problem! Thank you bro

    • @Pepcoding
      @Pepcoding  3 роки тому

      Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @pravinmudaliyar3421
    @pravinmudaliyar3421 2 роки тому

    Using prefix strategy:
    int n = s.length();
    for(int i = n - 1; i >= 0; i--) { // As we want the right side of strg[] to be filled initially, start traversing from behind.
    if(!dp[i][n - 1]) {
    int min = Integer.MAX_VALUE;
    for(int j = i; j < n - 1; j++) {
    if(dp[i][j]) {
    min = Math.min(min, strg[j + 1]);
    }
    }
    strg[i] = min + 1;
    }
    }
    return strg[0];

  • @dhanyaabharadwaj1376
    @dhanyaabharadwaj1376 3 роки тому +2

    Thank you so much for the video sir. Great effort! Extremely helpful!

  • @RBNrocks
    @RBNrocks 7 місяців тому

    Dil se thank you Sumeet Bhai

  • @dipanjanmaiti830
    @dipanjanmaiti830 3 роки тому +4

    can you please tell , in which video of yours ,gap strategy is explained?.....There is no video named as gap strategy .

    • @lasyapriya4076
      @lasyapriya4076 2 роки тому

      @Pepcoding where can I find gap strategy

  • @nehaagrawal670
    @nehaagrawal670 3 роки тому +2

    This code is not working for the string "aaabba". Could you please help?

  • @paragroy5359
    @paragroy5359 3 роки тому +1

    Very nice explanation sir....really good video...I truly appreciate your work

  • @devilronak7262
    @devilronak7262 3 роки тому +1

    Bro , literally your videos are very helpful, thx a lot for these wonderful videos

    • @Pepcoding
      @Pepcoding  3 роки тому +1

      Thank Bhai. Keep learning, Keep growing and keep loving Pepcoding!😊

  • @visheshmittal468
    @visheshmittal468 3 роки тому

    Sir one more thing
    Like in the end if there a prefix palindrome it will fail ex:- "aab"
    solution to that is:-
    for(int k=0;k

  • @ultimateroasts
    @ultimateroasts 9 місяців тому

    maza bhi aa gya aur samaj bhi ek number sir🔥🔥

  • @ananyakashyap4887
    @ananyakashyap4887 3 роки тому

    Very nice explanation.. Pehle 2 videos dekhi thi.. Par concept samaj Nahi aaya... After this I got it!! Thank you

  • @gdthegreat
    @gdthegreat 2 роки тому +1

    bhaiya thanks for great explanation,
    only small question is on website, In level 2, under DP, sequence after Matrix Multiplication is not matching as per your videos,
    as next 4-5 videos are ordered in reverse order, please check as per dependency of videos is matching to order.

  • @mickyman753
    @mickyman753 3 роки тому +2

    sir how can we generalise the questions , will this soltuion of variation of mcm could be used anywhere too?

  • @parasjain9416
    @parasjain9416 2 роки тому +1

    Dhanyawad

  • @charchitmangal
    @charchitmangal Рік тому +1

    Thank you so much bhaiya

  • @souvikpaul1153
    @souvikpaul1153 3 роки тому

    probably you and abdul bari sir are best on youttube for algos

  • @DeepakKumar-fh3jm
    @DeepakKumar-fh3jm 3 роки тому

    Your explanation is really good to understand. Thank you for making these videos.

    • @Pepcoding
      @Pepcoding  3 роки тому +1

      Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @hymnish_you
    @hymnish_you 3 роки тому +1

    Sir, you are such a fine teacher.

    • @AnkitSingh-xp7mm
      @AnkitSingh-xp7mm 3 роки тому +1

      Yes, every explanation simply touches your heart. That's pure teaching from Sumeet sir.

    • @AnkitSingh-xp7mm
      @AnkitSingh-xp7mm 3 роки тому

      BTW Himanshu, I am also at this level only in level2. Are you doing DSA regularly?

    • @hymnish_you
      @hymnish_you 3 роки тому

      Not currently Ankit. I have passed out from clg.

    • @AnkitSingh-xp7mm
      @AnkitSingh-xp7mm 3 роки тому

      @@hymnish_you Well pass out or not is not an issue. Anyways happy learning!!

  • @ratankumar1399
    @ratankumar1399 2 роки тому +1

    Thanks for creating such as awesome content sir.

    • @Pepcoding
      @Pepcoding  2 роки тому

      Glad it was helpful!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @pushpendrapratap3116
    @pushpendrapratap3116 3 роки тому

    one of the best explanations!!! Thank you

  • @akivibes
    @akivibes 3 роки тому

    Very smooth and nice explanation sir !!

  • @subhamyadav7269
    @subhamyadav7269 3 роки тому +1

    Nobody explained it better than you..sir

    • @Pepcoding
      @Pepcoding  3 роки тому +6

      thank you so much. ajkal to bache motivate bhi nahi karte. jo karte hain unke hum tahe dil se dhukargujaar hain. aapki support se he content bnane mei bhot madad milti hai

  • @vishwashdwivedi9469
    @vishwashdwivedi9469 3 роки тому +1

    Fantastic... !
    Great explanation !

  • @akanshapriya5392
    @akanshapriya5392 2 роки тому

    Thank you for explaining in such beautiful way.

    • @Pepcoding
      @Pepcoding  2 роки тому

      Glad it was helpful!
      For better experience and well organised content sign up on nados.io
      And for being updated follow us on Instagram instagram.com/pepcoding/

  • @adityaojha2701
    @adityaojha2701 3 роки тому +1

    Thanks for creating such as awesome content.

  • @abhishek__anand__
    @abhishek__anand__ Рік тому

    Superb Explanation

  • @srishtijaiswal7079
    @srishtijaiswal7079 2 роки тому +1

    Thank You so much sir for your videos
    I am having doubt what kind of questions that we need to solve for coding round?
    All these questions are for coding round or interview round?

  • @Jerry-fy2gc
    @Jerry-fy2gc 3 роки тому

    Thanks a lot. I was stuck from last 2 days.

  • @shubhampatel8655
    @shubhampatel8655 3 роки тому

    great content sir.No one teach like you.

  • @divyranjan254
    @divyranjan254 2 роки тому +1

    Why does the approach of taking only palindrome prefix/palindrome suffix reduce time complexity?

    • @Pepcoding
      @Pepcoding  2 роки тому

      For solving all your doubts, post your doubts on community tab of NADOS. Visit on nados.io

  • @mohammadanaskhan5294
    @mohammadanaskhan5294 2 роки тому

    Which video explains the basics of gap strategy from beginning

  • @harshitsharma7871
    @harshitsharma7871 2 роки тому +2

    Sir, can you please share the link to the video where you have explained the gap strategy.

    • @theuntoldtree
      @theuntoldtree 2 роки тому

      bhai mili?

    • @RAHUL-gf3ft
      @RAHUL-gf3ft 2 роки тому +1

      @@theuntoldtree count palindromic substring wali video hai

  • @RamSingh-ex4sp
    @RamSingh-ex4sp 2 роки тому

    best explanation possible!!

  • @raghavsinghhal5564
    @raghavsinghhal5564 3 роки тому

    really very helpfull......thank you 4 ur hardwork

  • @gurjarc1
    @gurjarc1 2 роки тому

    like your teaching methodology

  • @virajgavas3086
    @virajgavas3086 Рік тому

    gap strategy?? which vedio to refer

  • @dreamfollowerdreamfollower8553
    @dreamfollowerdreamfollower8553 3 роки тому

    Really great explanation. Thanks for providing such content.

    • @Pepcoding
      @Pepcoding  3 роки тому

      Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

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

    sir mere ko n^2 vala samaj nai aaya. aap ek side se palindrome kyo le ke chal rhe hai?

  • @mihiragarwal1269
    @mihiragarwal1269 2 роки тому

    Loved the video, great explanation

    • @Pepcoding
      @Pepcoding  2 роки тому

      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @mohitahlawat4944
    @mohitahlawat4944 3 роки тому

    great explanation sir, learned something new!(gap method)

  • @alpishjain1317
    @alpishjain1317 3 роки тому +1

    best video on youtube right now!

  • @karthikrashinkar204
    @karthikrashinkar204 3 роки тому

    2nd approach was lit 🔥🌪

  • @rohandevaki4349
    @rohandevaki4349 2 роки тому

    where is the gap strategy tutorial link?

  • @uddeshyakumar3245
    @uddeshyakumar3245 4 роки тому

    Sir test cases standard hote h na coz may be practicing on weak testcases causes issues in the real interviews
    please include all the variations of test cases in the problem.
    BTW Sir u are doing great work, honoured to learn.

  • @rapmusa
    @rapmusa Рік тому

    is this video in english somewhere else?

  • @RBNrocks
    @RBNrocks 7 місяців тому

    Can anyone please provide the link to Gap Strategy video of Sumit Sir?

  • @coderpriyabrat3585
    @coderpriyabrat3585 3 роки тому

    Thank you sir for this awesome details teaching

    • @Pepcoding
      @Pepcoding  3 роки тому

      So nice of you and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @coding_guru6992
    @coding_guru6992 2 роки тому

    Gap strategy wali videos kain si hai ? Please bta do koi ! Please

  • @durgeshrai04
    @durgeshrai04 3 роки тому +2

    Sir yah Gap strategy konse Video mai explain ke hai ?

    • @Pepcoding
      @Pepcoding  3 роки тому +1

      You will find the gap stratergy in this question -www.pepcoding.com/resources/data-structures-and-algorithms-in-java-levelup/dynamic-programming/count-of-distinct-palindromic-subsequences-official/ojquestion

    • @khushibansal1437
      @khushibansal1437 3 роки тому

      @@Pepcoding its not there sir

  • @ziaashraf3706
    @ziaashraf3706 3 роки тому

    i one of the best channels even

  • @ecea044gauravgogoi2
    @ecea044gauravgogoi2 3 роки тому

    thank you!

  • @artistic__08
    @artistic__08 3 роки тому

    Sir interview me bas approach batani hoti hai ya yeh bhi explain krna hota hai vo approach humne kaise sochi? Like how did we come to that approach?

  • @anirudhatalmale5575
    @anirudhatalmale5575 3 роки тому

    super awesome explanation

  • @rohandevaki4349
    @rohandevaki4349 2 роки тому

    please explain the code from line 9 to line 23 , the loop ,

  • @rohandevaki4349
    @rohandevaki4349 2 роки тому

    can you do this problem in recursion without going directly into DP sir?

  • @faisals.5790
    @faisals.5790 3 роки тому

    Code is wrong. below is the correct version. A little mistake . Second loop while go end till 0th index.
    int cuts[n];
    cuts[0]=0;
    for(int i=1;i=0;j--){
    if(j==0 && isPalindrome[j][i]==1){
    val=0;
    }

    else if(isPalindrome[j][i]==1){
    val = min(val,1+cuts[j-1]);
    }
    }
    cuts[i]=val;
    }

  • @namansingla2009
    @namansingla2009 3 роки тому +1

    Sir is there any recursive approach for the same. jumping directly on the bottom-up solution seems hard.

    • @Pepcoding
      @Pepcoding  3 роки тому

      Ji. I will soon do memoization

  • @vedant9887626061
    @vedant9887626061 3 роки тому

    Pretty good video .

  • @pankajbhatt5169
    @pankajbhatt5169 3 роки тому

    In the initial part when we are discussing the basic premise for the question before cutting we can make a check for the case when the whole string is palindrome otherwise that case if left ?

    • @mickyman753
      @mickyman753 3 роки тому

      yes we need a case there beacause by first way we already are adding a +1 of making a cut , if there is a string which has plaindromes in it but itself is a plaindrome too ,we will get wrong answer

  • @gorakhkumargupta491
    @gorakhkumargupta491 2 роки тому

    Just awesome

  • @abhishekchaurasia1055
    @abhishekchaurasia1055 2 роки тому

    Can anyone send the link of vdo where gap strategy is explained throughly??

  • @imranwahid9871
    @imranwahid9871 3 роки тому

    Thanks a lot sir.

    • @Pepcoding
      @Pepcoding  3 роки тому

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      ua-cam.com/users/Pepcodingabout?view_as=subscriber

  • @GauravKumar-ue7nz
    @GauravKumar-ue7nz 2 роки тому

    Thank you Sir

    • @Pepcoding
      @Pepcoding  2 роки тому

      For better experience and well organised content sign up on nados.io
      And for being updated follow us on Instagram instagram.com/pepcoding/

  • @arvindsinha1566
    @arvindsinha1566 3 роки тому

    Thanks. It is very tough solution.

    • @Pepcoding
      @Pepcoding  3 роки тому +2

      Glad you learned. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

    • @arvindsinha1566
      @arvindsinha1566 3 роки тому

      @@Pepcoding Done

  • @factswithai2
    @factswithai2 3 роки тому

    sir sawal thoda mushkil laga par ho gaya, thank u sir, east or west sumeet sir is the best

    • @Pepcoding
      @Pepcoding  3 роки тому

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @rohandevaki4349
    @rohandevaki4349 2 роки тому

    this code is not working

  • @SumitKumar-kh4kg
    @SumitKumar-kh4kg 2 роки тому

    OP 🔥🔥

  • @pritishpattnaik4674
    @pritishpattnaik4674 2 роки тому

    sir , in which video u have taught the gap statergy ?

    • @Pepcoding
      @Pepcoding  2 роки тому

      For such queries sign up on nados.io and post your queries on community section of NADOS, our alumni and mentors will help you.

  • @ADNANAHMED-eo5xx
    @ADNANAHMED-eo5xx 3 роки тому

    mazaa aagayi sirji

    • @Pepcoding
      @Pepcoding  3 роки тому

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @bismeetsingh352
    @bismeetsingh352 3 роки тому

    Ye gap strategy kya hai prerequisites me jo apne bola? Wo palindrome wala mtrix samaj me nai aya.

  • @dontgiveup5271
    @dontgiveup5271 2 роки тому

    At 19:00 did you say gap search? I'm hearing it for the 1st time.
    Can anyone say what exactly it is? Thank you in advance

    • @RAHUL-gf3ft
      @RAHUL-gf3ft 2 роки тому +1

      see count palindromic substring where gap method is discussed

  • @mehulbisht9708
    @mehulbisht9708 3 роки тому

    1:04 " to dekhiye hum kese karenge isko " , sir please insert that " bhai ye kese kar raha h " meme here 😂😂

  • @abhisheksinghchauhan5169
    @abhisheksinghchauhan5169 3 роки тому

    Why don't you use recursion + memoziation here ?

    • @nirajgusain4597
      @nirajgusain4597 3 роки тому

      because recursion + memorization code is giving TLE at all platform interviewbit,gfg,leetcode.

  • @manishkumarsingh4631
    @manishkumarsingh4631 2 роки тому

    28/79 Done

    • @Pepcoding
      @Pepcoding  2 роки тому

      Keep going. And for better experience and well organised content sign up on nados.io and keep learning.

  • @AnkitSingh-zj2uc
    @AnkitSingh-zj2uc 4 роки тому

    Sir BNY mellon ka hacker earth par trst hai oct mid mein kuch tips mil sakte hai prepration ke liye
    Foundation kar chuka hoon
    Aur l2 aapke saath kar raha hoon

    • @Pepcoding
      @Pepcoding  4 роки тому

      beta geeksforgeeks se BNY mellon ke interview experiences dekho.

  • @Codistency
    @Codistency 2 роки тому

    Sir where to watch gap strategy?

    • @Pepcoding
      @Pepcoding  2 роки тому

      For better experience and well organised content sign up on nados.io and start learning.

  • @mayankkumarthakur
    @mayankkumarthakur 2 роки тому

    O(n^3) solution shows TLE on LeetCode and GFG both.

  • @Asurgaming773
    @Asurgaming773 4 роки тому +1

    Sir ye topic book me to hai hi nahi.

    • @LeoLeo-nx5gi
      @LeoLeo-nx5gi 4 роки тому

      Shivam Agarwal bhaiya aap pls bata sakte ho ki aap konsi book ki baat kr rhe ho, please bhaiya book ka naam ya kuchh source bhej sakte ho kya, thanx🙏

  • @ishitsingh2837
    @ishitsingh2837 4 роки тому

    DP level 2 me 3 videos private ho chuki hain sir.
    Please look into it.

    • @Pepcoding
      @Pepcoding  4 роки тому +3

      beta private walio mei kuch galti hogi. kuch private nahi rakhna, jo content hoga sara public hoga

  • @shivangbhardwaj3165
    @shivangbhardwaj3165 3 роки тому

    29:52

  • @mehulmulchandani8126
    @mehulmulchandani8126 3 роки тому

    Sir yeh determine nahi kar paa raha hu ki dp array kab use karni h

  • @kumarkaustubh6188
    @kumarkaustubh6188 3 роки тому

    for "efe" im getting wrong ans acc to this approach on leetcode...expected ans is 0 but this code is giving 2.

  • @abhishekchaurasia1055
    @abhishekchaurasia1055 2 роки тому

    Sir you haven't explained gap strategy method thoroughly in any of your vdo... despite I have been watching your video in series.

    • @amaan8617
      @amaan8617 2 роки тому

      me bhi kab se yahi dundh raha hu ki konsi video me sir ne sikhaya hai gap strategy pr mila hi nhi toh kaha se sikha bro aapne?

    • @derilraju2106
      @derilraju2106 Рік тому

      @@amaan8617 Count palindromic substrings

  • @priyanshukhullar5836
    @priyanshukhullar5836 4 роки тому +1

    Sir ji Burst balloon

    • @Pepcoding
      @Pepcoding  4 роки тому +2

      ok beta. ek do din mei aa jaega. maine likha hua hai.

  • @vishalsingh-xx3ii
    @vishalsingh-xx3ii 4 роки тому

    SIR PLEASE YE BTA DIJIYE KI GRAPH KE QUESTION KAB SE START HOGA PLEASE SIR

    • @Pepcoding
      @Pepcoding  4 роки тому

      Abhi DP ke jis din 150 ho jaenge. Abhi abhi 62nd bnaya hai.

    • @anjneykumarsingh4461
      @anjneykumarsingh4461 4 роки тому

      Jo h vo smbhal ni rha ye kb vo kb

  • @AnkitSingh-zj2uc
    @AnkitSingh-zj2uc 4 роки тому

    Sir g speed increase kar lo please request, abhi shayad DP aadhi bhi nhi hui hai🙂

    • @Pepcoding
      @Pepcoding  4 роки тому +1

      han beta. poori koshish hai.

    • @Pepcoding
      @Pepcoding  4 роки тому +1

      62 out of 150 hue hain

  • @sarcaastech
    @sarcaastech 3 роки тому +1

    7 dislikes are by those jinke string me distinct characters h 😅