Find Beautiful Indices in the Given Array | Part I & II | KMP Algorithm | String Matching Algorithm

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • In this video, I'll talk about how to solve Leetcode 3008. Find Beautiful Indices in the Given Array II
    3008. Find Beautiful Indices in the Given Array II - leetcode.com/problems/find-be...
    3006. Find Beautiful Indices in the Given Array I - leetcode.com/problems/find-be...
    KMP CODE: leetcode.com/problems/find-be...
    Checkout DSA-169 Series: • Aryan DSA-169 Series |...
    100Days 100k Placements: • 100 Days 100K Placement
    Let's Connect:
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / ez.pz.dsa
    📱Telegram : t.me/aryan_mittal_group
    🤖 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 - Problem Explanation + Intuition
    5:18 - KMP (Knuth Morris Pratt) Algorithm - Building Up
    23:04 - Intuition of KMP working
    30:00 - Dry Run of Entire Algo with Code
    42:00 - Code Explanation
    47:00 - Time Complexity Proof
    53:00 - Continue Hard Problem Solving
    58:00 - Code Explanation of Hard Problem
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 31

  • @lavanyam3224
    @lavanyam3224 Před 8 dny

    The part where you explained the Intuition of KMP working is just out of the world!!

  • @SupriyoGhosh-gz3fs
    @SupriyoGhosh-gz3fs Před 3 měsíci +3

    You're just crazy I would say. Just crystal clear understanding of the most complex algorithm of dsa. Your effort = 100/100, understandability=100/100. Grateful towards you =100/100

  • @priyeshtandel2101
    @priyeshtandel2101 Před 20 dny +4

    I figured out why the balloon came, it was because you made a victory sign with your two fingers while explaining.😄

  • @asthajain2511
    @asthajain2511 Před 2 měsíci +1

    You're just crazy I would say. Just crystal clear understanding of the most complex algorithm of dsa. Your effort = 100/100, understandability=100/100. Grateful towards you =100/100
    🙂🙃

  • @syedmohammadarsalan2583
    @syedmohammadarsalan2583 Před 5 měsíci +13

    BEST VIDEO EVER ON KMP SIR 😍

  • @jayendrareddy9707
    @jayendrareddy9707 Před 4 měsíci +2

    I have already watched Neetcode video of kmp, but your version of KMP is best.I liked your video bro , thank you.

  • @abhinavkumar4375
    @abhinavkumar4375 Před 4 měsíci +2

    The number of times you have sent Broo to ask for matching the pattern , now he is not anymore bro he is telling "jaa khud puchkar aa ". Brooooo🤯

  • @k.satish3663
    @k.satish3663 Před 5 měsíci +3

    finally learned kmp .clean and clear explanation .
    thank you so much bro.

  • @kunalkumarshukla137
    @kunalkumarshukla137 Před 14 dny

    bhai ive watched at;east 10 15 videos on lps kmp but could'nt get the intuition for some time i could mug up..but forget after some time...this time i got the proper intuition thanks so much

  • @kkkkkkkkkk811
    @kkkkkkkkkk811 Před 4 měsíci +1

    "I wouldn't have said 'bro' this many times in my entire life as you did in this video alone 😂..But really nice explanation ❤"

  • @karthikeyanv4128
    @karthikeyanv4128 Před měsícem +1

    nice explanation👍

  • @ajaysubramaniam4453
    @ajaysubramaniam4453 Před 4 měsíci +1

    Thank you for the video.
    Understood everything about kmp.

  • @satishkumarpatra4896
    @satishkumarpatra4896 Před 2 měsíci +1

    I want to find O(M) space of LPS array i.e. to use only of pattern length. Where to find it?

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 Před 4 měsíci +1

    Best video on kmp Just awesome

  • @satwiktatikonda764
    @satwiktatikonda764 Před 4 měsíci +1

    btwn z-function and kmp wch one is good?

  • @sriramphysics5853
    @sriramphysics5853 Před 5 měsíci

    Good explanation

  • @AnirudhSharma-xe8je
    @AnirudhSharma-xe8je Před 5 dny +1

    35:42 iska intution ptaa hai kisiko aisa krne se answer kyu aara?

  • @rakeshvarma8091
    @rakeshvarma8091 Před 4 měsíci

    I couldn't wrap my head around the below line at czcams.com/video/Gr-eKRuWIQc/video.html:
    lps[i] = prev_idx + (s[i] == s[prev_idx] ? 1 : 0);
    How are you soo sure that if the character at index "i" matches with character at "prev_idx" then we can get the lps of current index by adding "prev_idx" to it ?
    I mean I agree that characters at index "i" & "prev_idx" match, but we don't have any idea about what character is at index "i-1" and whether it is in the longest suffix matching the prefix. Without this idea, how can we add "prev_idx" ?

  • @lilgainz
    @lilgainz Před 5 měsíci +2

    Brooo 🤯

  • @badrelmazaz
    @badrelmazaz Před 5 měsíci

    Hi, at the example with s = "aabaacaabaaa" the last lps element should be 2 not 0. Am I wrong? In my opinion should be like lps = [0, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 2] and not [0, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5, 0]. Timestamp: 9:23

    • @ARYANMITTAL
      @ARYANMITTAL  Před 5 měsíci +4

      Bro, ending character was a ‘d’ and not ‘a’ 🙃, though you are absolutely right, if it would have been ‘a’, lps would have been as you mentioned 🫡

    • @badrelmazaz
      @badrelmazaz Před 5 měsíci +2

      @@ARYANMITTAL Oh I got it, I'm sorry it seemed really an 'a' to me. Thanks for replying.

  • @codewithom11
    @codewithom11 Před 4 měsíci

    I am just not getting the intuition behind :
    If current character doesnt matches the previousindex character then why should we go to its previous index and repeat same process?
    Unable to understand intuition behind that while loop stuff!

    • @ARYANMITTAL
      @ARYANMITTAL  Před 4 měsíci

      I will suggest do Leetcode problem 3036 & 3031 (Write Problem name by Aryan Mittal) you will understand the usecase & importance of this while loop.
      If still have a confusion, then have a new comment, don’t reply on this comment as for me, it will not be visible, and tell what point you understood intuition and what point things doesn’t make sense, i’ll try replying there ❤️❤️

  • @onlysparsh
    @onlysparsh Před 4 měsíci +1

    KMP Game over thankss aryan bhaiya

  • @HoneySingh-yp7zc
    @HoneySingh-yp7zc Před 5 dny

    only me, jise kuch smjh nhi aaya?

  • @suyashsingh1715
    @suyashsingh1715 Před 5 měsíci +6

    Bhai please don't use "bhaiya" word, i think those who are watching your vedio are not your little brother can be your big brother. It feels bad please don't use it.

    • @Lucifer0872
      @Lucifer0872 Před 5 měsíci +8

      Don't watch his videos . We love him calling everyone bhaiya

    • @ok-google-run
      @ok-google-run Před 5 měsíci +4

      he's our sweet bhaiya. bhaiya is ageless. Focus on his explanation rather than the pronouns. I am a girl so should I give him a bash for not calling out in girl pronouns?!

    • @Spyro-kt8gy
      @Spyro-kt8gy Před 20 dny +2

      You're so ungrateful bro.