Tap to unmute

29 Print shortest common Supersequence

  Рет қаралды 173,615

Aditya Verma

Aditya Verma

Күн бұрын

Пікірлер
@utsavprabhakar5072
@utsavprabhakar5072 5 ай бұрын
This is the first time I am doing this. I know this hardly makes any difference but this is probably the only way I can say thank you to you. Cheers. I know this playlist is “old” now but I am pretty sure this is what people refer to when they say “old is gold”
@shivangishukla2629
@shivangishukla2629 4 жыл бұрын
you are teaching at 3 in the morning! everyone watching your videos truly appreciate your efforts! thank you so much. Dropping this comment to make you feel motivated to keep making videos! it's a blessing for all of us.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks Shivangi !! It really means a lot ✌️💕
@spoidermon4323
@spoidermon4323 3 жыл бұрын
@@TheAdityaVerma bro atlast we should reverse the string,try to pin this comment everyone can see
@Gobu_69
@Gobu_69 3 жыл бұрын
@@Surajkumar-hy4mh 😂😂😂
@nishant1720
@nishant1720 Жыл бұрын
@@TheAdityaVerma bhai tree aur graph wagera ki bhi bna dete saath m
@ShravanMauryaYouTube
@ShravanMauryaYouTube 6 ай бұрын
Really❤❤❤
@autismo1969
@autismo1969 2 жыл бұрын
No one has ever taught dp this well. No one will ever teach dp this well ever. You're a legend. Thanks 🙏
@TheAdityaVerma
@TheAdityaVerma 2 жыл бұрын
Appreciate the kind words mate !
@swapnil1035
@swapnil1035 2 жыл бұрын
@@TheAdityaVerma sir why are you not teaching nowadays??
@Vishal-ds6ly
@Vishal-ds6ly Жыл бұрын
@@TheAdityaVerma sir you are the best teacher on youtube please make a graph playlist.
@ramjain3923
@ramjain3923 4 жыл бұрын
This is LC hard problem and you made it look like a "halwa"(easy) question . Thanks bhai!
@akashpurbia4390
@akashpurbia4390 4 жыл бұрын
Dark season 4 should be made on your playlist because "everything is connected ".
@amanlateef7773
@amanlateef7773 4 жыл бұрын
LoL 😂
@abhishekbajaj109
@abhishekbajaj109 4 жыл бұрын
nice one mate'
@amansinghal2431
@amansinghal2431 4 жыл бұрын
bro I was listning to dark soundtrack in the background, and i seriously thought "wow a glitch in youtube, comment section of dark is showing in this video's comment sections!"
@sayantanbanerjee821
@sayantanbanerjee821 4 жыл бұрын
This comment is lit
@onkartelange8812
@onkartelange8812 4 жыл бұрын
zaher bhai !
@satyamrajsingh7378
@satyamrajsingh7378 4 жыл бұрын
Sir Your teaching style is impeccable.Far better than other youtubers
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks it meant a lot, Please share it among your friends to make it famous.
@christianoronaldo1662
@christianoronaldo1662 4 жыл бұрын
@@TheAdityaVerma do we have to reverse the string in the end ?, i did it on leetcode and i had to reverse it to pass all the test cases . btw thanks for your effort !!
@awesomeps10
@awesomeps10 4 жыл бұрын
@@christianoronaldo1662 woah Ronaldo even knows how to code, GOAT 🙏😂
@rahuljain5642
@rahuljain5642 3 жыл бұрын
@@TheAdityaVerma Very much better than other KZbinrs, I referred other playlists but yours is best. But the solution you are providing us don't get submitted in leetcode directly. Kindly check into this.
@gautamjain6275
@gautamjain6275 3 жыл бұрын
@@TheAdityaVerma share hi to nhi krna chte competition bhaut h market me
@anushkamandal8788
@anushkamandal8788 11 ай бұрын
You mentioned it was 2.49 AM in the video...and at that instant only I looked at the clock and it showed 2.49 AM. What a coincidence! PS- Thanks for such a great DP series. It really reduced my fear in DP and boost my confidence
@dishanamdev2620
@dishanamdev2620 4 жыл бұрын
"Laal Phool, Neela Phool Aditya Sir ki teaching beautiful"... Thanks a lot, sir....
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Raho imandaar, dont take bribe..please like share and subscribe :D
@dishanamdev2620
@dishanamdev2620 4 жыл бұрын
@@TheAdityaVerma DP by you to kesi bribe, ab hum log krenge interviewers ki hawa tight😂.. Aur han mat kro chinta, I already subscribed❤✌😁.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Interviewer pooche question to dena answer sahi aur keh dena usse jo kisine kisi se kaha nahi sau baato ki ek baat h wahi dhoodh me daaloge jamun to mn jaaega dahi :D
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thats it ! I am not gonna write no more. Peace out 😂✌️
@dishanamdev2620
@dishanamdev2620 4 жыл бұрын
@@TheAdityaVerma haha Same here🤣
@0anant0
@0anant0 4 жыл бұрын
28 of 50 (56%) done! Nice explanation! Thanks for burning the midnight oil for us.
@webdev_telugu
@webdev_telugu 4 жыл бұрын
If you directly jump to a random video on this series you'll be like: "What the hell is this guy teaching?" if you come from the very first video of the series, you'll get to know that no one can teach DP better than him
@amanpreetsinghsetia1524
@amanpreetsinghsetia1524 3 жыл бұрын
Exactly!
@rounakbhatia5995
@rounakbhatia5995 2 жыл бұрын
++
@yatin3699
@yatin3699 2 жыл бұрын
++
@psycholife8960
@psycholife8960 Жыл бұрын
++
@ajaybhagchandani3307
@ajaybhagchandani3307 4 жыл бұрын
Bro currently it's 2:45AM here., and I'm watching your videos with enthusiasm. :D Able to understand a few questions before you begin which sums up your success in explanation abilities. Loved it. Thanks.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Bro its 2:56 AM and I am reading your comment. Thanks for watching ✌️❤️
@nitinbajpai6050
@nitinbajpai6050 4 жыл бұрын
@@TheAdityaVerma where is 27 video ?? bro
@rajatbudania6181
@rajatbudania6181 4 жыл бұрын
@@TheAdityaVerma make more videos plzzzzzzzzz!!
@shashankgupta29
@shashankgupta29 4 жыл бұрын
watching the full playlist till now and have shared this with my friends !!😊😊 Lots and love and respect for you SIR ❤❤🙌!!
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks brother !!
@vinnu245
@vinnu245 2 жыл бұрын
Small correction in d code: Inside the while loop in the else statement we also need to check= case also while pushing into d string t[i-1][j]>=t[i][j-1] now push it into string and also make sure to reverse the string at d end !!! Hope it helps :)
@harshulsharma4683
@harshulsharma4683 Жыл бұрын
yeah that we all get but this is not working
@harshulsharma4683
@harshulsharma4683 Жыл бұрын
it is working😅
@sohiltr2310
@sohiltr2310 Жыл бұрын
yes simply write "else" there
@amanagarwal7578
@amanagarwal7578 Жыл бұрын
i am getting TLE please help class Solution { public: string shortestCommonSupersequence(string str1, string str2) { int m=str1.size(); int n=str2.size(); int t[m+1][n+1]; for(int i=0;it[i-1][j]){ s.push_back(str2[j-1]); j--; } } } while(i>0){ s.push_back(str1[i-1]); i--; } while(j>0){ s.push_back(str2[j-1]); j--; } string ans=""; for(int i=s.size()-1;i>=0;i--){ ans.push_back(s[i]); } return ans; } };
@aryandumyan1195
@aryandumyan1195 Жыл бұрын
@@amanagarwal7578 same bhai.. mera bhi 2nd test case pe tle aa rha hai...any idea how to do it?
@muskanchoudhary9792
@muskanchoudhary9792 3 жыл бұрын
Kudos to you !! We could not even do coding at 3 am and you are doing so much for all of us. Thankyou so much. This video has best explanation with motivation :)
@ashisharora0077
@ashisharora0077 4 жыл бұрын
Dude your teaching style is just mind blowing!! I've been following your DP tutorials from the very first video and now everything has become so intuitive its like You give me a problem i'll follow exactly n steps and will come up with a solution in this question also same thing happened "Print SCS" i followed the intuition you've been giving since the very first video and the problem automatically got broken into small easier problems and tada!! I automatically got to the answer BEST Dynamic Programming TUTORIALS TILL DATE!! Keep making video bro! and Please make videos on Trees & Graphs also
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks for watching dude !! Do share to help this channel grow if this channel helped you !!
@mohammadanas2432
@mohammadanas2432 4 жыл бұрын
iss playlist ka bad maine ye sikha.. hai ki koi cheez hard ni hoti agar acha teacher ho tumhara..Thank you Aditya Bhai
@hindunationalist3447
@hindunationalist3447 2 жыл бұрын
Q- why are we adding a[i-1] when t[i-1][j]>t[i][j-1] and b[j-1] for t[i][j-1]>t[i-1][j] to answer string? Ans- when t[i-1][j]>t[i][j-1] this is true then we move to upside of the current element in matrix because t[i-1][j] is greater but when we move to upside we may lose the ith char of a(a[i-1]) so we will add it first to ans , the j th char of b(b[j-1]) may be added later because we are still in same column of current element(jth col). Similar reason when we move to left side of the current element in matrix(t[i][j-1]>t[i-1][j]). Credit : Anurag Alvala.
@rituraj-1311
@rituraj-1311 3 жыл бұрын
My first Leetcode hard problem submission made easy by you. Thank You!!
@ghazanferwahab5673
@ghazanferwahab5673 3 жыл бұрын
mera tle dera kyun
@raht9578
@raht9578 2 жыл бұрын
@@ghazanferwahab5673 string shortestCommonSupersequence(string str1, string str2) { int n=str1.size(); int m=str2.size(); int dp[n+1][m+1]; for(int i=0;i0){ if(str1[i-1]==str2[j-1]){ ans.push_back(str1[i-1]); i--; j--; } else if(dp[i-1][j]>dp[i][j-1]){ ans.push_back(str1[i-1]); i--; } else{ ans.push_back(str2[j-1]); j--; } } while(i>0){ ans.push_back(str1[i-1]); i--; } while(j>0){ ans.push_back(str2[j-1]); j--; } reverse(ans.begin(),ans.end()); return ans; } try this
@nikhilpawariaaa
@nikhilpawariaaa 2 жыл бұрын
@@ghazanferwahab5673 mera bhi
@jayshree7574
@jayshree7574 4 жыл бұрын
your passion is inspiring coders like me, pls never stop making these amazing vids.
@nikhilkumarsingh2082
@nikhilkumarsingh2082 4 жыл бұрын
@Jayshree finally got a heart after commenting on almost every video..good
@jayshree9037
@jayshree9037 4 жыл бұрын
@@nikhilkumarsingh2082 no my first comment on this channel got heart + reply. And plus I don't actually care about that. I am just expressing myself whether i get a heart or not!
@nikhilkumarsingh2082
@nikhilkumarsingh2082 4 жыл бұрын
@@jayshree9037 just kidding..ya I know that it's not about heart or like , it's about to show respect towards same person we are learning.
@adityamaurya9277
@adityamaurya9277 4 жыл бұрын
@@nikhilkumarsingh2082 and you are stalking her in comment section lol!
@sakshamsengar9798
@sakshamsengar9798 3 жыл бұрын
mere mu ke baat cheen li aapne!!!!! :)
@nitinojha9826
@nitinojha9826 4 жыл бұрын
You made Dynamic programming so Easy. Bro Your hard work will pay off.
@codetochange8
@codetochange8 2 жыл бұрын
Teaching at 3 am in the morning...Hats off to your dedication..
@SwastikBarpanda
@SwastikBarpanda 4 жыл бұрын
Started watching it at 2:49 AM and it's coincidental.....keep up the good work bhaiya!
@nehayadav1164
@nehayadav1164 4 жыл бұрын
same .....
@sharufcat8911
@sharufcat8911 3 жыл бұрын
agar ap jaisa har teacher india me padhane lage to har student ka class me mann lagega.... aur sochiye india kitna aage jaiga ... agar ap jaise teacher ka number badh jaye india me to..... you are the best teacher .... i really want u to continue this ....please...
@thedanglingpointer8411
@thedanglingpointer8411 4 жыл бұрын
Great video. Just one correction in the explanation. When the characters are not equal, then we should include the char in which direction we are NOT moving. :)
@faizan346
@faizan346 4 жыл бұрын
he pushed those characters in the string watch it again
@priyakoshta7129
@priyakoshta7129 3 жыл бұрын
Yes there is correction
@divyanshtiwari5540
@divyanshtiwari5540 3 жыл бұрын
I was looking for this correction !!! thanks bro XD
@adityahridyam7698
@adityahridyam7698 3 жыл бұрын
was looking for this comment...thanks
@mickyman753
@mickyman753 3 жыл бұрын
he didn't explained this , so but was doing this , thnaks for confirming this also we are printing chars between two common chars pairs of the 2 strings, moving in the direction of more value ele and printing less value ele beacuse , the more value index can be potenitally added later but we are leaving this less ele index for all the process so must be included
@gourav.barkle
@gourav.barkle 3 жыл бұрын
* Little Correction at 13:46, SCS would be 'acbcdaf' of length 7.
@_ApoorvaShinde
@_ApoorvaShinde 4 жыл бұрын
"Raat k 2:49AM hore hai and mai padhara hu"....dedication dekhre ho bande ka ...daba k share karo iske videos!!
@jayshree7574
@jayshree7574 4 жыл бұрын
unlike others i am watching it at 2 pm on a beautiful rainy dayyy!!! my final exam starts from tueday, stiil hooked onto this series. I can't wait for EDIT DISTANCE, that question is a nightmare for me
@asakhala
@asakhala 3 жыл бұрын
aap hum sab ke khate ki tapasya kar rahe hai...taki hume na karni pade....kitne questions aapne solve kiye honge tab jake itni clearity hai thought aur concept mai....hats off
@balajiabhi9039
@balajiabhi9039 2 жыл бұрын
I can think its obviously miracle @Aditya Verma. you're teaching at 3AM in the morning and I am watching this video 3AM in the morning. Its a kinda content that any person can quickly addict to it. Well done for your great commitment to provide us this kinda beautiful and valuable content. Thanks a million Brother😍
@priyarathore9266
@priyarathore9266 3 жыл бұрын
Best DP course on internet , for free but gold!
@himanshugupta7010
@himanshugupta7010 3 жыл бұрын
now i am able to figure out the solution of most of the question even before start of the video . Thanks a lot man for building this skill in me .
@debarandas3470
@debarandas3470 3 жыл бұрын
Beyond of my expectation❤God may give you more and more peaceful and energetic life. You are a true gem. Love from Kolkata. Love a btech student who was struggling to learn DP. Love and respect from a student who is now capable of understanding DP very much after watching your videos.
@debarandas3470
@debarandas3470 3 жыл бұрын
Love* from
@ngtv5608
@ngtv5608 3 жыл бұрын
Need a playlist on GRAPHS !!
@spoidermon4323
@spoidermon4323 3 жыл бұрын
check out codencode, it is nice
@uyadav8258
@uyadav8258 3 жыл бұрын
@@spoidermon4323 right
@meghaagrawal3676
@meghaagrawal3676 9 ай бұрын
Very good videos to learn DP, really no one has ever explained DP like this and how to approach a given problem statement. Best playlist to watch to crack coding rounds.
@aashimaa2681
@aashimaa2681 2 жыл бұрын
This is LC hard and you solved it like an easy problem! Love you dude
@AshishKumar-kf5xy
@AshishKumar-kf5xy 2 жыл бұрын
It was a really helpful explanation. It was a bit tricky to understand as to why and how we will include the uncommon characters from the string but your explanation has made everything clear.
@kushalappaca5324
@kushalappaca5324 2 жыл бұрын
Cant thank you enough for these videos.
@Vendettaaaa666
@Vendettaaaa666 4 жыл бұрын
Moving on to 30th video. Abhi mere paas do choices hai. Next video click karun yaa nahi. Toh uske liye hum code like sakte hain :D :P Love the videos!
@neerajpatil5076
@neerajpatil5076 2 жыл бұрын
You are a ultimate teacher . I never achieved this level of understanding on dp questions before . Thanks to you 😃
@23cash86
@23cash86 Жыл бұрын
Neeraj....
@sohiltr2310
@sohiltr2310 Жыл бұрын
just wanted to let you know that you are truly making the world a better place thanks a lot sir
@sarveshverma7378
@sarveshverma7378 3 жыл бұрын
Nice video again. if top > left, we have come from string a; so copy a's current element a[i-1] and move up else we have come from string b; so copy current s1 element s1[i-1] and move left
@gauravshah7888
@gauravshah7888 2 жыл бұрын
Bhaiya ne DP nahi jaadu sikhaya hai!! Bina dekhe first try mei solve kar liya ! Thank You!!
@krushnapawar7513
@krushnapawar7513 Жыл бұрын
Great Work Aditya This Series Helps me a Lot to Improve My DSA skills
@asakhala
@asakhala 3 жыл бұрын
you are a magician! Just solved LC HARD question for the same which is, got it done in 5 mins without any errors or reruns. If it were not for you, I wouldn't have even dreamt of attempting it. How can we say thank you, brother? Would love to give back to you directly.
@autismo1969
@autismo1969 2 жыл бұрын
Thanks aditya you legend
@TheAdityaVerma
@TheAdityaVerma 9 ай бұрын
Thanks bhai !
@sumekagarwal8229
@sumekagarwal8229 4 жыл бұрын
Damn it!..........no other channel is so explanatory. You are really shredding dope man! Thank you so much for this!
@nehalkashif
@nehalkashif 3 жыл бұрын
in last else if check.. we should do ">=".. coz in strings where more than one lcs exists.. both dp[m][n-1] and dp[m-1][n] may be equal sometimes.
@thevijayraj34
@thevijayraj34 2 жыл бұрын
You're right
@deepakjoshi4374
@deepakjoshi4374 4 жыл бұрын
3:28 a:m or me ye video dekhra hu.... lock -down khtm hone tak dp me command bnani hai... Thank You Sir.... ap bhoot acha pdaa rhe ho
@lifecodesher5818
@lifecodesher5818 4 жыл бұрын
bani command?
@deepakjoshi4374
@deepakjoshi4374 4 жыл бұрын
Haan... Now, I can solve most of the Dp based questions. But yes, there are some expections like dp using bits, dp on trees and some other dp based Q's which I'm not able to solve.
@lifecodesher5818
@lifecodesher5818 4 жыл бұрын
@@deepakjoshi4374 yes yes very visible I was leetcoding yesterday and saw your post and I was like I think I have seen him somewhere now I remember where I saw you😂😂😂😂😂😂😂😂😂 anyways keep going!
@deepakjoshi4374
@deepakjoshi4374 4 жыл бұрын
😂😂 well yes, I have written 20-30 editorials in leet code. I want to give back to my community.❤️💙
@GamingBooDance
@GamingBooDance 2 жыл бұрын
He is the best teacher I have ever seen!!!!Keep growing .
@kartikag01
@kartikag01 11 ай бұрын
this is LC hard problem, and i have coded all my myself. amazing dude.
@yashmittal9040
@yashmittal9040 4 жыл бұрын
bro your videos are amazing i watched the playlist from the start and was able to figure everything except the last two while loops on my own
@sharufcat8911
@sharufcat8911 3 жыл бұрын
devta aadmi ho yaar ap... free me aisa video ap bna ke youtube pe daal re ho... aise bahut kam log milte hain.... sbko paise kmane ki padi haii... but ap hi ek ho jo free me itna acha padha re ho.... really appriciate your work bro
@harshita6683
@harshita6683 Жыл бұрын
Thankyou so much for creating such playlist, i am actually loving to solve these questions by myself.
@krishnachaitanya3080
@krishnachaitanya3080 3 ай бұрын
Aap exactly 2:49 am ko padha rhe h...aur mein exactly 2:49 am par padh rha hu. BTW great content and organization of concepts!!! Really helping a lot.
@shreyasharma4042
@shreyasharma4042 3 жыл бұрын
Before you start explaining the solution I came up with one . I don't know how to thank you man.
@shobhitranjan3957
@shobhitranjan3957 3 жыл бұрын
Very Helpful! Please explain problem "Find the Shortest Superstring" as well!
@himanshugiri4214
@himanshugiri4214 2 жыл бұрын
Can you please make a video on the graph concepts....because after learning DP from video,i think you can teach the whole DSA which can be far better than the other you tubers,You are just Awesome Aditya Bhaiya
@RandomShowerThoughts
@RandomShowerThoughts Жыл бұрын
Bhai you are a real one, teaching at 3 AM
@Rohit_Gunwal
@Rohit_Gunwal 6 ай бұрын
Thank You bhai 😊 was able to solve this myself without watching the video because i completely understood the concept of printing LCS tweaked that logic a bit and solved it.
@vakhariyajay2224
@vakhariyajay2224 Жыл бұрын
Thank you very much. You are a genius.
@saurav0203srivastav
@saurav0203srivastav 2 жыл бұрын
Cant like this video enough!!!! Damn you are Good Man, you literally made a LC Hard so Easy. And i genuinely feel bad for those who haven't found you yet!!!! Thanks a ton.
@bhumikasharma5033
@bhumikasharma5033 3 жыл бұрын
the only channel where I like the video before watching it
@rajatmehta8499
@rajatmehta8499 4 жыл бұрын
Bro me kaafi dino se dp sochra tha krne ko or thoda sa mn ata tha ki bhut mushkil ogi butt after watching your videos u made dp so easy thanks a lotttttt🙏🏾
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks brother, Do subscribe and share, that keeps me motivated to do more !!
@MohddAlii
@MohddAlii 3 жыл бұрын
Greatest of the great lectures on dp
@pranshujain6752
@pranshujain6752 3 жыл бұрын
i can't think any other teacher whenever dp topic comes into my mind,this guy really one shot killl the dp..... hats off to you sir........
@HimanshuSingh-bd8sp
@HimanshuSingh-bd8sp Жыл бұрын
following the series from start. wonderful stuff aye aye
@medamsaisirisha847
@medamsaisirisha847 Жыл бұрын
aap raat ke 2.49 AM pe padha rahe hai aur hum subah ke 6 baje tak binge watch krke problems solve kr rhe, truly amazing series great work
@prinzuchoudhury6920
@prinzuchoudhury6920 4 жыл бұрын
if(a[i-1]==b[j-1]) to S.push_back(a[i]) ki jagah S.push_back(a[i-1]) nhi hona chaiye tha?
@pavan9184
@pavan9184 3 жыл бұрын
Yes, it should be S.push_back(a[i-1])
@sakshamsengar9798
@sakshamsengar9798 3 жыл бұрын
yes bro u r right
@uyadav8258
@uyadav8258 3 жыл бұрын
yes bro
@lalitjain98
@lalitjain98 4 жыл бұрын
baaki log pehle hi ek matrix banake rakhte hain aur darate zada hai, your videos are gold man!
@aakarshyadav2812
@aakarshyadav2812 4 жыл бұрын
In the 18th minute and thereafter, there is an error. The contents of the two ifs block need to interchange, that is:- a[i-1] should be pushed instead of b[j-1] and b[j-1] should be pushed instead of a[i-1] Please review. Thanks.
@AISynthetic
@AISynthetic 4 жыл бұрын
yes exactly please rectify
@manishitachoudhary528
@manishitachoudhary528 4 жыл бұрын
else if(t[i][j-1]>t[i-1][j]) { s.push_back(X[i-1]); i- -; } else s.push_back(Y[j-1]); j- -; good observation. I think this should be the correct code
@rishabhthakur2270
@rishabhthakur2270 2 жыл бұрын
@@manishitachoudhary528 does this work?? it didnt work in my case
@hitabratanath305
@hitabratanath305 2 жыл бұрын
@@manishitachoudhary528 in if block there should be j-- and in else it should be i--
@rajarishabh5987
@rajarishabh5987 3 жыл бұрын
u are doing a sacred job brother love u...
@SAGARSINGH-em3xm
@SAGARSINGH-em3xm 4 жыл бұрын
at 17:27 why we use s.push_back(b[i-1]) can we use s.push_back(a[i-1])
@abhinavgupta6940
@abhinavgupta6940 3 жыл бұрын
no u can't use a
@rajatagarwal1800
@rajatagarwal1800 2 жыл бұрын
if top > left, we have come from string a; so copy a's current element a[i-1] and move up else we have come from string b; so copy current s1 element s1[i-1] and move left
@TheIndianGam3r
@TheIndianGam3r 4 жыл бұрын
Just a correction. if(t[i][j-1] > t[i-1][j]) we actually add i-1st character not the greater one as we are moving towards greater anyways. Here, in your example when we check c with d, we actually add d to ans not c as we are moving towards c which has a max value in table. Great video tho!!
@manasikasande9400
@manasikasande9400 4 жыл бұрын
His solution is correct, I tried it on leetcode and my submission was accepted
@AJ-gg1jc
@AJ-gg1jc 4 жыл бұрын
yeah bro you are right as if we are initializing i = m then pushing a[i] would add nothing so we have to push_back a[i-1] and also there is something you can notice that ....... what you take as n and m..... here sir took m = a.length() and n = b.length()...... if you took different then you have to make changes in whole code..... and yeah it is accepted at leetcode ..... i was also confused due to n and m ..... the concept is same you just have to track the i and j with either n or m which depends on what you've taken as lengths of a and b.... Here is my accepted code where i took n = a.length() and m = b.length()... leetcode.com/submissions/detail/385530895/
@amritgupta5703
@amritgupta5703 4 жыл бұрын
@@AJ-gg1jc i have done like n , m you have taken ,its not working ,can u please share ur code link from any code sharing platform , we cant see from leetcode as leetcode URLs are not public . please
@AJ-gg1jc
@AJ-gg1jc 4 жыл бұрын
@@amritgupta5703 This is my leetcode SCSS code: collabedit.com/8a6jb
@satvinderpalsingh9124
@satvinderpalsingh9124 4 жыл бұрын
yes right
@ketanverma4615
@ketanverma4615 Жыл бұрын
Aditya Bhai badiya padaya h aapne pr yr har video m 😂😂 "Ase koi nahi padayega " "Rat k 2:49 hore h "
@KUSHALLOYA
@KUSHALLOYA 5 ай бұрын
Great videos Bhaiya!!! Just one more thing to add on, basically LCS is intersection of 2 strings and SCS is union of 2 strings(in the same order obv). Hope this helps.
@bhawanagupta236
@bhawanagupta236 4 жыл бұрын
You are awesome bro. Deep respect for you.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks a lot sis !! Do subscribe and share if possible, to help this channel grow.
@lucy-uo6bt
@lucy-uo6bt 4 жыл бұрын
Great Explanation!!🙌 ..just one thing why are we adding a[i-1] when t[i-1][j]>t[i][j-1] and b[j-1] for t[i][j-1]>t[i-1][j] to answer string? Is there a logic behind this or just observation?Thanks in advance...
@anuragalvala2113
@anuragalvala2113 4 жыл бұрын
when t[i-1][j]>t[i][j-1] this is true then we move to upside of the current element in matrix because t[i-1][j] is greater but when we move to upside we may lose the ith char of a(a[i-1]) so we will add it first to ans , the j th char of b(b[j-1]) may be added later because we are still in same column of current element(jth col). Similar reason when we move to left side of the current element in matrix(t[i][j-1]>t[i-1][j]).
@aindrilasaha1592
@aindrilasaha1592 3 жыл бұрын
@@anuragalvala2113 Great explanation!!Thanks a lot, was confused on this earlier.
@ashutoshaman9783
@ashutoshaman9783 3 жыл бұрын
@@anuragalvala2113 but in lcs table if the a[i-1]is not equal to b [j-1]then we should add both as te they are un comman character so we must add both of them.a little bit confusing please help
@sahilsingh1155
@sahilsingh1155 3 жыл бұрын
@@ashutoshaman9783 no we can not ...if u do so then which way u will move. In either way you move eventually u will add one character again because when a[i-1][j ] > b[i][j -1] we are moving only one side ie: i-- so only one character will be added and that character will be at index which we are changing
@syamsreemanojreddy1027
@syamsreemanojreddy1027 3 жыл бұрын
@@anuragalvala2113 had this doubt. beautiful explanation.
@keshavraghav3896
@keshavraghav3896 2 жыл бұрын
Already done this in scs previous video by myself... Thanks for teaching us at these hours....
@sarthaktyagii7683
@sarthaktyagii7683 2 жыл бұрын
best dp playlist ever you make dp look so easy man kudos to you
@workandearnwithshubhi9050
@workandearnwithshubhi9050 3 жыл бұрын
Bhaisahab itta maja coding padhne mai kabhi nahi aaya hai jitta aditya bhaiya ke lectures mai aata hai !!!!
@csin6166
@csin6166 3 жыл бұрын
Bhaiya, for the test case: AGGTAB and GXTXAYB, after the first while loop the string(in reverse) would be: BYAXTXG, and then first while loop will get terminated, but "AG" is still remaining, so it will get into while loop specific for string1, and it will push back all the left characters of string1 in answer string i.e first G and then A, therefore, the output string(reverse) would be: BYAXTXGGA which after reversing is: AGGXTXAYB, which is wrong because the answer string must be: AGXTXAYB I think we need to check if the current char is in both the strings or not and then push back if not present for the remaining part of string
@pranjalshinde1586
@pranjalshinde1586 2 жыл бұрын
This is happening in recursive solution but Aditya's answer is fine for top down approach
@Akz77977
@Akz77977 4 жыл бұрын
correction: SCS = acbcdaf (not acbcaf at 13:47)
@divyrajsingh8711
@divyrajsingh8711 3 жыл бұрын
hard work pays off 2:49 to teach other hats off
@djb155
@djb155 3 ай бұрын
Love for ur efforts and hats of to ur talent.
@SUMITKAUSHIK1000
@SUMITKAUSHIK1000 2 жыл бұрын
Ur the best I mean I would have bought ur videos without any regret
@codeguru9543
@codeguru9543 2 жыл бұрын
Thanks for this video. Learnt something new.
@parvmethi1661
@parvmethi1661 3 жыл бұрын
Please make playlist on graphs also so that it will be super easy for us like dp.
@meenukumari2974
@meenukumari2974 3 жыл бұрын
Your videos are really very helpful. Thank you so much
@karthikkallur727
@karthikkallur727 3 жыл бұрын
Really loved your interest in teaching us❤️❤️❤️
@jaynandwana8878
@jaynandwana8878 8 ай бұрын
one of the best question till now.
@parijatgarg3172
@parijatgarg3172 4 жыл бұрын
Fabulous work,, dropping a comment so that you stay motivated!! Indebted for this knowledge that you are sharing!! KUDOS TO YOU :)))))))))))
@nishantpruthi1172
@nishantpruthi1172 2 жыл бұрын
DP God ADITYA 😘😘, Can't thank you bro for this much help.
@smartcoding174
@smartcoding174 2 жыл бұрын
great teacher of dp.... thanks for your efforts sir...
@shivankchaturvedi4817
@shivankchaturvedi4817 4 жыл бұрын
bhai kya toh gazab h content learned a lot from u love from NIT JAIPUR
@lone_wolf7721
@lone_wolf7721 3 жыл бұрын
Rat ke 2:41 pe aap padha rahe ho main din ke 2:41 pe padh raha hoon what a coincidence ♥╣[-_-]╠♥
@vikantbhati4935
@vikantbhati4935 4 жыл бұрын
Awesome bro Your teaching way is ultimate Thank you .
@pratikkumar9434
@pratikkumar9434 4 жыл бұрын
gzab pdhaye hai .dp ka baja fad diye ekdum
@ARYANSHARMA-ph8ss
@ARYANSHARMA-ph8ss 3 жыл бұрын
agar kisi ne pehle ki videos dekhi hai toh they dont even need to watch this video. thats is the real power of DP lmao
@auroshisray9140
@auroshisray9140 2 жыл бұрын
Succinct way of teaching...thanks a lot sir
30  Longest repeating subsequence
12:58
Aditya Verma
Рет қаралды 203 М.
24 Shortest Common SuperSequence
22:59
Aditya Verma
Рет қаралды 202 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
23  Printing Longest common subsequence
26:45
Aditya Verma
Рет қаралды 242 М.
40 Evaluate Expression To True Boolean Parenthesization Memoized
28:12
19  Longest common subsequence Recursive
27:42
Aditya Verma
Рет қаралды 297 М.
22  Longest Common Substring
13:00
Aditya Verma
Рет қаралды 262 М.
Life is set up for everyone to win
12:00
The Ultimate Freedom Podcast
Рет қаралды 2
G-46. Disjoint Set | Union by Rank | Union by Size | Path Compression
42:15
Why Your Brain Sabotages Your Goals (and How to Fix It)
11:56
Productive Peter
Рет қаралды 28 М.
20  Longest common subsequence Memoization
31:19
Aditya Verma
Рет қаралды 196 М.
37  Palindrome Partitioning Memoization
18:54
Aditya Verma
Рет қаралды 110 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН