Word Pattern Matching using Backtracking | Leetcode Solutions in JAVA
ฝัง
- เผยแพร่เมื่อ 22 ม.ค. 2025
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we explain the word pattern matching using recursion and backtracking where:
1. You are given a string and a pattern.
2. You've to check if the string is of the same structure as pattern without using any regular expressions.
.....................................................................................................................................................................
Pepcoding has taken the initiative to provide counselling and learning resources to all curious, skilful and dedicated Indian coders. This video is part of the series to impart industry-level web development and programming skills in the community.
For better experience and well organised free resources visit -
We also provide professional courses with live classes and placement opportunities.
DSA Level 1 and Level 2
www.youtube.co...
Webinar on GATE Preparation
• Video
Here is a roadmap to our Free study content and know more about our resources here -
We are also available on the following social media platforms: -
Facebook(Meta) - / pepcoding
Instagram - / pepcoding
LinkedIn - / pepc. .
Pinterest - / _c. .
Twitter - / pepcoding
TH-cam (English Channel)- / @pepcodingprogrammingi...
Also take a look at our placement assistance -
HAPPY PROGRAMMING!
Pep it up.....
#recursion #backtracking #leetcode
did it on my own Thanks to god and Summet Sir
Great Explanation bro!!!........
arrey sir, yeh tshirt badiya hai ekdum!
haha. thank you. webinar karao, aapko bhi bhej denge. Also a very cool laptop bag.
sir bahut mast but I have one suggestion for you please write time-complexity and space complexity in editorials on pepcoding portal for this questions specially backtracking vaale
Noted
you are awesome sir
Sir what about pattern "abba" and string "dog dog dog dog" here this is taking dog as 'a' and dog as 'b' and we want 'dog' to be only taken by exactly 1 character of pattern. Hence it is given false for this case and my output is coming true.
Beta mera solution is case mei false he dega
@@Pepcoding No sir its giving true
Tm space hta do to a=dogd , aur b=og ,se ye ho jayga
alag level :)
thank you. If you like the content, please share and subscribe. If you can help me get a webinar, we can send you some cool pepcoding goodies
sir i had 2 major doubts ,
1) 14:41 sir , are these answers also valid as per the given problem ?
{p=g, e=oodbad}
{p=go, e=odbad}
{p=goo, e=dbad}
{p=good, e=bad}
{p=goodb, e=ad}
{p=goodba, e=d}
2) also, sir if we are given first string as "ppe" or "epp", but not "pep" but the other string is the same, i.e. "graphtreesgraph", will this approach still work ?
for 2. yes, ppe aur epp ke case mei answer he nahi aaega. same order jaroori hai.
for 1. yes
@@Pepcoding nice to hear this ! otherwise i would be thinking that the code that i made without watching solution was incorrect !
Time complexity?
Great Explanation sir! we are putting only unique chracters in the map so why we need to use hashset again
Because the answer has to be printed in same order as the original pattern. If we loop on map.keySet() then it will give answer in random order.
Was able to do without watching the video. Thanks!
Glad I could help!
Sir telegram channel link no exist
t.me/pepcoding
Sir isme ek issue aaskta hai , lets say string is dogdog and pattern is ab, then there will be a case where it will map 'a' with "dog" and 'b' will also be " dog" , basic according to this , two different characters can have the same mapping.
make a map of count of values , if count of any value is >1 then dont print
here dog->2 so dont print just return
please discuss time and space complexity, mene try kiya derive karne but difficult laga.
hanji. bhool ja rha hai. shuru karunga
but this doesnt work! I tried it with same code .. did anyone tried it??
@@Kashish_Batra can you share the leetcode link of your solution?
lot of likes :)
Sir deeply tree answer tak ka bnana pda tab jaker clear huwa actually ho kya rha hai question ka logic pakdne me thoda thoda miss ker ja rha hu i think sir practice kerte rahunga ek din jaruar ho jayega
Hanji beta, aise he lge rho aur sbka euler tree bnane ki koshish kiya kro.
I think this solution would fail with this test case => pattern: "ab" and string: "aa"
Aaj 5 savaal minimum 🙈
poori koshish rahegi. 2sra bna dia already. aa rha hai
Sir goodies asey hi mt dijiye koi contest k through milta toh mza ata
apne paas 3000 bag rakha hai. aise bhi kar lenge aur waise bhi