Palindrome Partitioning Dynamic Programming

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 2024
  • Given a String S, find the minimum number of cuts required to separate the string into a set of palindromes.
    This video explains the solution to palindrome partition problem using dynamic programming.
    Source code link:-
    github.com/IDe...
    Website: www.ideserve.co.in
    Facebook: / ideserve.co.in

ความคิดเห็น • 64

  • @gyanasahu1006
    @gyanasahu1006 3 ปีที่แล้ว +2

    There is a better approach to constructing this dp table. The flaw here is we are constructing row by row and we have to look at row + 1 for updating dp[row][1..]. Do it by length, which is more intuitive. Below is the code:
    for(int i=1; i

  • @IDeserve
    @IDeserve  8 ปีที่แล้ว

    Dear Friends,
    If you like our content and would like us to continue making great content for you, please spread the word about IDeserve.
    A share/appreciation from you on social network would mean the world to us!
    Also, do like our Facebook page: facebook.com/IDeserve.co.in :)
    Thanks,
    -Team IDeserve.

  • @NitinSingh-hk3vy
    @NitinSingh-hk3vy 2 ปีที่แล้ว +1

    Thanks brother, this video helped me a lot🙌. Keep doing 👍

  • @sujan_kumar_mitra
    @sujan_kumar_mitra 3 ปีที่แล้ว +1

    Nice Explanation

  • @rishitgupta7848
    @rishitgupta7848 3 ปีที่แล้ว +1

    Thank you!

  • @aadityasharma9790
    @aadityasharma9790 2 ปีที่แล้ว +1

    you deserve more subscriber man!

  • @Ice-2706
    @Ice-2706 4 ปีที่แล้ว +2

    Thanks bro and keep posting more videos they are helpful !!

  • @anonymoussloth6687
    @anonymoussloth6687 2 ปีที่แล้ว

    Brute force would be 2^n because u r not checking all substrings. U r checking all valid cuts. You have n positions where you can place the cut and you have two options at each position to cut it or not cut it

  • @blatogh1277
    @blatogh1277 3 ปีที่แล้ว +1

    that makes my life easier. In my opinion, to test whether is a palindrome, we just need to have a test function to go over the substring and determine whether this substring is palindrome or not.

  • @haimbendanan
    @haimbendanan 8 ปีที่แล้ว +4

    Why is the brute force n^3 ?
    All the string partition possibilities aren't 2^(n-1) ? Or am I missing something?
    Thanks!

    • @11m0
      @11m0 7 ปีที่แล้ว

      I dont get it either...Did u figure this out?

    • @neerajjoshi9493
      @neerajjoshi9493 7 ปีที่แล้ว +1

      actually brute force here refers to another DP approach which is not as good as this DP approach.

    • @manjesh80
      @manjesh80 6 ปีที่แล้ว

      Its n^2 + n^2 . === n^2 ... compare to other approaches .. which is n^3
      If n = 1000
      n^2 ==> 1000000 ==> 1 Million
      n^3 == 1000000000 ==> 1 Billion
      n^2 + n^2 ==> 2 Million

    • @shiwanggupta8608
      @shiwanggupta8608 6 ปีที่แล้ว +1

      Actually its not brute force..using brute force it would be O(n*2^n)
      using dynamic programming we can achieve O(n^2) using different approach
      www.geeksforgeeks.org/dynamic-programming-set-17-palindrome-partitioning/

  • @lifehacks9450
    @lifehacks9450 4 ปีที่แล้ว +2

    Please upload more why did u stopped

  • @aniket7512
    @aniket7512 4 ปีที่แล้ว +3

    God Level Explanation. Thanks bro was finding this whole day !

    • @IDeserve
      @IDeserve  4 ปีที่แล้ว +1

      Wow! Thanks Aniket!

    • @aniket7512
      @aniket7512 4 ปีที่แล้ว

      @@IDeserve Bro u truly deserve it. I guess that's why u named d channel IDeserve😂....Jokes apart keep uploading great content 😊 ATB

  • @karthiknedunchezhiyan5136
    @karthiknedunchezhiyan5136 7 ปีที่แล้ว +1

    Instead of keeping boolean matrix it is easy to count the minimum cut in matrix itself.....
    then return top right corner value

  • @himanshusrihsk4302
    @himanshusrihsk4302 4 ปีที่แล้ว +1

    Best Explanation ever. Sir plz provide solutions for problem in leetcode medium and hard questions

  • @pathikritchanda62
    @pathikritchanda62 3 ปีที่แล้ว +1

    Thank you sir for this approach , hope for such great content in future too .

  • @hoyinli7462
    @hoyinli7462 2 ปีที่แล้ว +1

    you are the only 1 DP solution I really understand! Thank you!

    • @IDeserve
      @IDeserve  2 ปีที่แล้ว

      Thanks Ho Yin Li!!

  • @kushal1
    @kushal1 4 ปีที่แล้ว +2

    Great video... Just one thing I didn't get the intuition behind dp[j] + 1. Difficult to understand. Dry run makes little more sense but still. Could have been explained better.

  • @chrisogonas
    @chrisogonas 3 ปีที่แล้ว +1

    WOW, that was helpful. Thanks

  • @namanvijay3514
    @namanvijay3514 3 ปีที่แล้ว +1

    Best explanation 👍

  • @falakk22
    @falakk22 7 ปีที่แล้ว +1

    Amazing , please keep adding more probs . Is there any book that we should refer to look out for such questions ? Any recommendation . Thanks .

    • @vorasagar7
      @vorasagar7 6 ปีที่แล้ว

      solve leetcode or use ctci for questions

  • @anmoljain5846
    @anmoljain5846 2 ปีที่แล้ว

    thank you, sir. I was trying to get it from many resources, finally, I got it through this video

  • @bhavukgarg3619
    @bhavukgarg3619 5 ปีที่แล้ว +1

    Sir your videos are always helpful, Just got to search for that ideserve logo, and my doubts are clear.

    • @IDeserve
      @IDeserve  5 ปีที่แล้ว

      Thanks for your kind words Bhavuk!

  • @34_harshdeepraghuwanshi98
    @34_harshdeepraghuwanshi98 3 ปีที่แล้ว +1

    Awesome 15 min explanation

    • @IDeserve
      @IDeserve  3 ปีที่แล้ว

      Thanks Harshdeep!

  • @SurendraSingh-hp9gk
    @SurendraSingh-hp9gk 5 ปีที่แล้ว +1

    thank you ideserve.

  • @mkay7800
    @mkay7800 3 ปีที่แล้ว +1

    Its Awesome 🔥🔥

  • @ameyapatil1139
    @ameyapatil1139 4 ปีที่แล้ว +1

    Excellent work !

  • @mohakchaudhary1981
    @mohakchaudhary1981 5 ปีที่แล้ว +1

    Best explanation of this problem 🎈⚡⚡😀

    • @IDeserve
      @IDeserve  5 ปีที่แล้ว

      Thanks Mohak!

  • @Vinny254
    @Vinny254 3 ปีที่แล้ว

    Tried to print the substrings ... anyone managed to get the minimum substrings as a list instead ?

  • @varunnarayanan8720
    @varunnarayanan8720 4 ปีที่แล้ว +1

    Well explained..

  • @vicentefelipe4287
    @vicentefelipe4287 7 ปีที่แล้ว

    loved this video, super helpful, can you do Palindrome Partitioning, where you return all possible palindrome partitioning of s. For example, given "aab". return [["aa","b"], ["a","a","b"]]

  • @Sushil2874
    @Sushil2874 4 ปีที่แล้ว +1

    Nice explanataion..!!

    • @IDeserve
      @IDeserve  4 ปีที่แล้ว

      Thanks Sushil!

  • @08JuHan
    @08JuHan 4 ปีที่แล้ว +1

    great tutorial! thanks a lot for your help

    • @IDeserve
      @IDeserve  4 ปีที่แล้ว

      Thanks!

    • @sajalagrawal1430
      @sajalagrawal1430 4 ปีที่แล้ว

      @@IDeserve why have you stopped uploading?

  • @karthiksharma8720
    @karthiksharma8720 5 ปีที่แล้ว +1

    Sir you are awsome

    • @IDeserve
      @IDeserve  5 ปีที่แล้ว

      Karthik you are awesome 😊

  • @justanaverageguy4739
    @justanaverageguy4739 4 ปีที่แล้ว

    this is O(n^3) solution right?

  • @ZiiiP2142
    @ZiiiP2142 7 ปีที่แล้ว +1

    Awesome.

    • @IDeserve
      @IDeserve  7 ปีที่แล้ว

      Thanks primaltare for your kind words :)
      We would really appreciate if you could spread the word about IDeserve in your college and to your colleagues.
      Also please check out our website at: www.ideserve.co.in
      It has features like Algorithm Visualization, Learn Together and many more coming soon.
      Please check it out and leave us a comment there!
      Thanks,
      -Team IDeserve.

  • @shaivalchokshi3424
    @shaivalchokshi3424 8 ปีที่แล้ว +1

    Nice, thank you :)

    • @IDeserve
      @IDeserve  8 ปีที่แล้ว

      +shaival chokshi
      Thanks a lot for your words! It is very encouraging to hear such comments!
      We would really appreciate if you could spread the word about IDeserve in your college and to your colleagues.
      Also please check out our website at: www.ideserve.co.in
      It has features like algorithm visualizations, learn together and many more coming soon.
      We are uploading new topics everyday.
      Please check it out and leave us a comment there!
      Thanks,
      -Team IDeserve.

    • @shaivalchokshi3424
      @shaivalchokshi3424 8 ปีที่แล้ว

      Yes, i've been watching a lot of videos of yours :) they're all too helpful

    • @IDeserve
      @IDeserve  8 ปีที่แล้ว

      +shaival chokshi
      Thanks a lot for appreciating!

  • @varunkunchakuri1204
    @varunkunchakuri1204 8 ปีที่แล้ว

    i don't think there is brute force way of o(n^3) please check

    • @pownarthithimiridayasagar2229
      @pownarthithimiridayasagar2229 8 ปีที่แล้ว

      I think, by Brute force they mean calculating min cut for every possible substring in the string.

    • @bipul2138
      @bipul2138 4 ปีที่แล้ว

      That one is also based on DP

  • @harveylastname1523
    @harveylastname1523 8 ปีที่แล้ว +1

    The table of 2D information is not used all, you can save the integer but not boolean only.Save the min(T[i][j] = 1+ Min(T[i][k] , T[k][j-1]) to the table 2D, so the T[i][j] is the answer.

  • @lemonginger001
    @lemonginger001 6 ปีที่แล้ว

    explained nicely :)

    • @IDeserve
      @IDeserve  6 ปีที่แล้ว

      Thank you so much Yash for your kind words :)