@@circleofcoding I think writing j = 0 will give error. Try for this string "acccbaaacccbaac". I think you need to write j = lp[j-1] as you need to move to the next part of the already found suffix substring of this array
Great explanation but ek cheez samaj nhi aai. Shouldn't we only consider the suffixes ending at end of the entire string, as we want to find the longest one for the entire string and not a substring?
@@circleofcoding I got that afterwards. But I still don't understand the full KMP algorithm. KMP is more than building the LSP array. It's about finding a string in another string. It will be great if you could do a video on how to use the LSP array to match strings.
Perfectly explained theory!
very very nice explanation brother shi me pura concept clear ho gya is que. ka !!!!
Thanks bro. Plzz share this channel among your friends..
Bro, at 13:54, you explained wrong. 'j' will not shift to '0', j will be equal to lps[j-1]
Yes, i think i have said it wrong, but in code part, it is right..
Thank you. KMP bhi samjha dijye.
waah guru kya hi btaya hai yaar maze aagye smj kr, bs last m equation nahi btayi j = lp[j-1].
great bhai
bs solution dalna bnd mt krna is sheet ke
ye sheet bhot bdiya hai
or app bhi bhot ache se explain kr rhe ho sbhi question
Hnn, plzz share this channel among your friends. Thanks in advance.
j=0 kyu nhi likh rhe seedha? j= lp[ j-1 ] kyu krna pdra h bhaiya, hr baar j ko 0 ke equal nhi krna padega jab bhi s[i] and s[j] unequal honge?
Har baar 0 se nhi krna hai n, jaha se match hona suru hoga, waha se compare krenge n.. Ekbaar dry run krke dekho dono case ko, tab smjh aayega..
bro in the else part why you put j=lp[j-1] and not j=0 as we have to start from the beginning
It's the standard way to write it, j=0 is also correct. U can go with either..
@@circleofcoding I think writing j = 0 will give error. Try for this string "acccbaaacccbaac". I think you need to write j = lp[j-1] as you need to move to the next part of the already found suffix substring of this array
@@swagatochakraborty6043 thankss for clearing this
@@circleofcoding it is not correct in all cases. testcase - acccbaaacccbaac. isko krna glt aayega
very good explanation
Great explanation but ek cheez samaj nhi aai. Shouldn't we only consider the suffixes ending at end of the entire string, as we want to find the longest one for the entire string and not a substring?
Then it will be string itself. Right..
@@circleofcoding I got that afterwards. But I still don't understand the full KMP algorithm. KMP is more than building the LSP array. It's about finding a string in another string. It will be great if you could do a video on how to use the LSP array to match strings.
@@DK-ox7ze ok, i will make a video if there will be KMP algo.
can you try these test case: it is failing on leetcode q number 1392 acccbaaacccbaac
jo samjkaye ho and code me difference hai