Knuth–Morris–Pratt (KMP) Pattern Matching Substring Search -  First Occurrence Of Substring

Knuth–Morris–Pratt (KMP) Pattern Matching Substring Search - First Occurrence Of Substring

Back To Back SWE

5 лет назад

143,601 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

LN
LN - 11.08.2023 10:40

Greatly explained, i saw a couple other videos but yours made me really understand it

Ответить
mase
mase - 05.08.2023 01:15

KING 👑

Ответить
Robert Pearson
Robert Pearson - 31.07.2023 07:53

I can tell coders for normal people. Normal people count 1, 2, 3, … Coders do not count, they calculate memory address offsets 0, 1, 2,…

Ответить
Robert Pearson
Robert Pearson - 31.07.2023 07:50

So you want to find the location of each proper suffix which is also a prefix of the pattern?

Ответить
oliver Free
oliver Free - 25.07.2023 14:35

explained very well thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Ответить
xskinyx
xskinyx - 12.07.2023 12:31

It's a little misleading as to what part of the algorithm actually "saves work". Positive values in the KMP table force the algorithm to backtrack and try different parts of the match string p against s. Because the KMP table accounts for backtracking, the search through s can continue on after mismatches, without backtracking, as long as there are no entries in the KMP table. So even if the lookup table were completely empty, this offers a huge speedup

Ответить
Abhijit Sarkar
Abhijit Sarkar - 10.07.2023 11:43

(volume - 10) + (repetition / 10) = watchable.

Ответить
Thomas
Thomas - 25.06.2023 11:40

Very, very poorly explained.

Ответить
Joe
Joe - 24.05.2023 23:29

Thanks you're awesome.

Ответить
Leon V
Leon V - 24.05.2023 05:44

So far this is the first algorithm that made me stop and think for a while

Ответить
Sumit Arora
Sumit Arora - 21.05.2023 02:50

Excellent explanation!

Ответить
Balveer Singh
Balveer Singh - 18.01.2023 19:24

wow

Ответить
dudu
dudu - 27.12.2022 17:06

I love his energy. Hard to loose focus.

Ответить
Manny Medina
Manny Medina - 27.12.2022 03:13

why are you yelling bro?

Ответить
George Yarr
George Yarr - 06.12.2022 13:20

Hi, what is the point in making an entry in the border table for the last character in the substring? As there cant be a mismatch that requires its use? Once you get to that point in the substring you'll either find a match and the algorithm terminates, or you find a mismatch and look at the border of the table[0...7]

Ответить
Animesh Pandey
Animesh Pandey - 02.12.2022 01:19

thansk man

Ответить
Piyush Jain
Piyush Jain - 26.09.2022 09:22

Top-notch content

Ответить
Henry Sun
Henry Sun - 21.09.2022 04:12

Thank you~

Ответить
Eurotool
Eurotool - 19.09.2022 01:58

Advance one to be recognized

Ответить
Samarth Saxena
Samarth Saxena - 16.08.2022 11:25

Can we just concatenate, the first string and find the position of second string like if it exits?

Ответить
Shivam Kumar Singh
Shivam Kumar Singh - 11.07.2022 14:41

Great Video,KMP is now crystal clear to me .Thanks !!!
Love from India♥

Ответить
it85x30
it85x30 - 28.06.2022 03:39

Unrelated but Donald Knuth's last name is pronounced like "Ka-Nooth" Great explanation, very clear.

Ответить
Satakshi Pal
Satakshi Pal - 19.06.2022 07:11

you explained it so nicely

Ответить
Caligula
Caligula - 01.06.2022 17:26

Brilliant explanation - certainly one of the best for the KMP algorithm. I like how you focus on the intuition behind the algorithm, as opposed to the traditional textbook approach. Have you considered writing a book on algorithms?

Ответить
De Goya
De Goya - 24.05.2022 00:32

do they really think we'll be able to come up with this shit on our own in 30 minutes during a technical interview??

Ответить
Excerption Excerption
Excerption Excerption - 20.04.2022 04:52

Perfect explanation. Thank you so much!

Ответить
Anupam Kumar
Anupam Kumar - 13.04.2022 16:17

Terrific 🔥🔥

Ответить
Vipin Kumar
Vipin Kumar - 08.04.2022 07:26

You are becoming my first choice for learning any new algorithm. Keep uploading👍 Hats off👏

Ответить
WhisperII
WhisperII - 29.03.2022 22:25

Yay I think I understand it at last, thanks man!

Ответить
Yudi Zhang
Yudi Zhang - 17.01.2022 00:13

Thanks! Very clear, detailed and energetic!!

Ответить
SHILIN WANG
SHILIN WANG - 13.01.2022 17:27

Find the longest suffix which is also the prefix to save us from reverting the searching. Thanks!

Ответить
Nikunj Sondawale
Nikunj Sondawale - 09.01.2022 16:35

it was a great help. Thanks man

Ответить
cyka blyat
cyka blyat - 09.01.2022 15:49

what a bs video, you failed to utilize the best example of the algorithm... now you've literally matched from start to end

Ответить
Emmanuel
Emmanuel - 06.01.2022 09:09

You've got the gift of explaining the concept

Ответить
20bec006_VINEET TIWARI
20bec006_VINEET TIWARI - 26.12.2021 20:32

well done bro

Ответить
Hussain Alramadan
Hussain Alramadan - 21.12.2021 20:27

Thank you from my heart.
I was about to give up on this algorithm, until I found this video, I appreciate this work so much.

Ответить
bmbharath
bmbharath - 19.12.2021 02:25

just amazing explanation bro!

Ответить
Md Tauhidul Azim
Md Tauhidul Azim - 15.12.2021 13:35

dude you need to chill when explaining

Ответить
Jason C.
Jason C. - 14.12.2021 07:16

Leetcode easy????

Ответить
lycan
lycan - 29.11.2021 22:18

never been so confused

Ответить
eeee
eeee - 29.11.2021 20:52

I hope I am never asked this question, great explanation.

Ответить
Pheezx Coding
Pheezx Coding - 22.10.2021 19:22

Amazing content. I've been going through your videos and they are so helpful!

Ответить
barry_allen
barry_allen - 13.10.2021 11:44

Great explanation. I never got the intuition of why prefix/suffix works, but not anymore !

Ответить
Anthony's Office
Anthony's Office - 12.10.2021 02:32

Pretty good explanation

Ответить
Psuedo Coder
Psuedo Coder - 24.09.2021 10:56

Function to create the lpsArray according to explanation :-

public static void lpsArray(String s) {
int a[] = new int[s.length()];
a[0] = 0;
int i = 0;
for (int j = 1; j < s.length(); j++) {
if (s.charAt(j) == s.charAt(i)) {
i++;
a[j] = i;
} else {
if (i - 1 < 0) {
i++;
}
i = a[i - 1];
a[j] = i;
}
}
for (int x : a) {
System.out.print(x + " ");
}
}

Ответить