Coding Interview Patterns Z Algorithm - Matching Patterns in A String

preview_player
Показать описание
This is the first video in Series of Patterns we encounter during Leetcode Weekly and Biweekly Contests.
In this video, we cover Z Algorithm - A String Matching Algorithm which is famous and helps solve a lot of string related problems.

More problems to practice

00:00-3:43 String Matching Problem and Brute Force way
3:44-7:04 Z Array and what it stores?
7:05-9:56 O(N^2) way to calculate Z Array
9:57-14:28 Optimising to O(N) - Major idea
14:29-17:00 Major idea code for Z
17:01-22:23 Optimising - What if less characters match?
22:24-29:23 Optimising - What if more characters match?
29:24-30:52 Using Z array for String matching
30:53-36:55 Code
Рекомендации по теме
Комментарии
Автор

After you explained both the cases where naively picking from the z[i - l] will fail and then seeing your code, it becomes so much clearer . Thank you so much

wrishavbhattacharyya
Автор

all other videos I have seen on this algorithm were very confusing but you are the only one who has explained this so well. thank you so much!

terabaap
Автор

Nice explanation. I coded it myself after you explained the approach, without seeing your code. Hope to see more string matching algo videos from you

Dontpushyour_luck
Автор

Such a perfect explanation!
Not even the top Competitive Programmers explained the algorithm this easily.

Tenebrous-leyt
Автор

this was so well explained. i found it hard to understand before this video but now i understand what the algorithm is actually doing!!

hashirshaikh
Автор

Too good. I wish you had more subscribers

mohammadkaif
Автор

Bhaiya please make dedicated videos on KMP and Rabin Karp as well
Your method of explanation is very good.

Also is Boyer Moore Algorithm for Pattern Searching used in contest?

vyomgoyal
Автор

Only ones who understand the algorithm themselves can explain it this well. Kudos Bharat, very well done video. So nicely explained!!

mainwhihoon
Автор

Thanks Bhaiya.
Bhaiya Please make video on Sweep Line Algorithm and DP+Bitmask.

shubhamrai
Автор

must needed video bhaiya, because in past contest, ,there were direct question on z-function and i was unable to understand it.thanks

chetan.s.bandurkar
Автор

I feel this is toughest one, i spend more than 2 hours to understand the optmise steps

learnAndMove
Автор

Thank you for the explanation. Can you please make videos on KMP and Rabin Karp too please

architroychoudhury
Автор

A lil bouncer for me, will use the code for zMatch in the questions where pattern$string can be use ( for the time being, samgh ni aata )

aniketsharma
Автор

Please make video on kmp algorithm also 🙏

Cools
visit shbcf.ru