Coding Interview Patterns Z Algorithm - Matching Patterns in A String
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.
Code of Z Algorithm: ideone.com/bOv5J4
More problems to practice
Longest Happy Prefix: leetcode.com/problems/longest...
Password: codeforces.com/contest/126/pr...
Connect on Insta: / bharatkhanna1995
Connect on Linkedin: / bharat-khanna-717b4817b
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
Пікірлер: 28
Such a perfect explanation! Not even the top Competitive Programmers explained the algorithm this easily.
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!
awesome explaination
Only ones who understand the algorithm themselves can explain it this well. Kudos Bharat, very well done video. So nicely explained!!
@CodingwithBharat
2 ай бұрын
Thanks man!
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
@CodingwithBharat
4 ай бұрын
Great! Will plan it out ✌️
Thank you so much for the video.
@CodingwithBharat
4 ай бұрын
✌️✌️
Great explanation
@CodingwithBharat
2 ай бұрын
Thanks!
must needed video bhaiya ,because in past contest ,,there were direct question on z-function and i was unable to understand it.thanks
@CodingwithBharat
4 ай бұрын
Keep coding Chetan! 🫡
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?
@CodingwithBharat
4 ай бұрын
Hi Vyom! Thanks and yes will make those too. Regarding Boyer Moore Voting Algorithm, that is a different technique.
@vyomgoyal3125
4 ай бұрын
I am talking about Booyer Moore String Matching Algorithm
@CodingwithBharat
4 ай бұрын
@@vyomgoyal3125Oh! Yeah that is not common one to be asked.
@vyomgoyal3125
4 ай бұрын
@@CodingwithBharat Ok Thanks
Thanks a lot
@CodingwithBharat
4 ай бұрын
✌️
Good Explanation
@CodingwithBharat
Ай бұрын
Thanks
Thank you for the explanation. Can you please make videos on KMP and Rabin Karp too please
@CodingwithBharat
4 ай бұрын
Yes will plan to.
Please make video on kmp algorithm also 🙏
@CodingwithBharat
4 ай бұрын
Sure
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 )
@CodingwithBharat
4 ай бұрын
What parts got confusing?