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

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

Пікірлер: 31

  • @SupriyoGhosh-gz3fs
    @SupriyoGhosh-gz3fs3 ай бұрын

    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Ай бұрын

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

  • @syedmohammadarsalan2583
    @syedmohammadarsalan25836 ай бұрын

    BEST VIDEO EVER ON KMP SIR 😍

  • @asthajain2511
    @asthajain25113 ай бұрын

    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 🙂🙃

  • @jayendrareddy9707
    @jayendrareddy97074 ай бұрын

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

  • @lavanyam3224
    @lavanyam322421 күн бұрын

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

  • @k.satish3663
    @k.satish36636 ай бұрын

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

  • @abhinavkumar4375
    @abhinavkumar43755 ай бұрын

    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🤯

  • @ajaysubramaniam4453
    @ajaysubramaniam44535 ай бұрын

    Thank you for the video. Understood everything about kmp.

  • @kunalkumarshukla137
    @kunalkumarshukla13727 күн бұрын

    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
    @kkkkkkkkkk8115 ай бұрын

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

  • @sukhpreetsingh5200
    @sukhpreetsingh52005 ай бұрын

    Best video on kmp Just awesome

  • @karthikeyanv4128
    @karthikeyanv4128Ай бұрын

    nice explanation👍

  • @sriramphysics5853
    @sriramphysics58536 ай бұрын

    Good explanation

  • @satishkumarpatra4896
    @satishkumarpatra48963 ай бұрын

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

  • @satwiktatikonda764
    @satwiktatikonda7644 ай бұрын

    btwn z-function and kmp wch one is good?

  • @AnirudhSharma-xe8je
    @AnirudhSharma-xe8je18 күн бұрын

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

  • @rakeshvarma8091
    @rakeshvarma80915 ай бұрын

    I couldn't wrap my head around the below line at kzread.info/dash/bejne/eaZhx62LpbqvgcY.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
    @lilgainz6 ай бұрын

    Brooo 🤯

  • @badrelmazaz
    @badrelmazaz5 ай бұрын

    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

    5 ай бұрын

    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

    5 ай бұрын

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

  • @onlysparsh
    @onlysparsh5 ай бұрын

    KMP Game over thankss aryan bhaiya

  • @codewithom11
    @codewithom115 ай бұрын

    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

    5 ай бұрын

    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 ❤️❤️

  • @HoneySingh-yp7zc
    @HoneySingh-yp7zc18 күн бұрын

    only me, jise kuch smjh nhi aaya?

  • @suyashsingh1715
    @suyashsingh17156 ай бұрын

    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

    6 ай бұрын

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

  • @ok-google-run

    @ok-google-run

    6 ай бұрын

    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

    Ай бұрын

    You're so ungrateful bro.