Nice solution sir! I would like to add one point here: the answer strings will always have an extra space character at the end, so if we want to avoid that, we will need to pop back the character from string before printing our answer.
@MGtvMusic3 жыл бұрын
Yes exactly,I just used ans.substring(0,ans.length()-1)
@manpreetsinghrana7751 Жыл бұрын
use s.trim() before you display the result. It will clear all white spaces after the string
@jaivishwakarma304 Жыл бұрын
when u r cpp coder but still watches his video because of quality explanation
@deeptarkoroy67243 жыл бұрын
Thanks sir.I did this ques without watching the video,its all because of u.
@Pepcoding3 жыл бұрын
Glad to hear that Keep learning, Keep growing and keep loving Pepcoding!😊
@vikkasmaheshwari8622 жыл бұрын
Isme right string bnane ki bjaye hm index pass kr skte hai
@jatinkumar44102 жыл бұрын
Very nice explanation sir. I have a doubt. It is normal recursion right? Then why is it considered in backtracking? Also please explain its time and space complexity...
@harmanjeetsingh35562 жыл бұрын
Your are my fav teacher sir!! i dont like to watch others video anymore
@shrutiemu4 жыл бұрын
Sir your explanation is phenomenal and it gives clarity to the thinking process. But I faced certain time limit exceeded scenarios when the input is too huge .How can we handle such scenarios using recursion
@Pepcoding4 жыл бұрын
beta DP ki hongi. Recursion ke baad DP mei convert karna hoga
@arvindsinha15663 жыл бұрын
I faced same issue of time exceed. I solved using memoization technique without using DP
@harmanjeetsingh35562 жыл бұрын
@@arvindsinha1566 it gives in gfg, use top down approach with memorization instead of tabulation, it will save some calls, here we are finding every combination, time complexitywise both are same
@bluesteel1 Жыл бұрын
Thanks sir. Neat explanation
@bibhusingh24 жыл бұрын
When was the Sumeet sir next Webinar.? . Because i really need to talk to him! Please sir take a next Webinar as soon as possible.🙏
@Pepcoding4 жыл бұрын
aj sham 7 bje ek mock interview types hai
@bibhusingh24 жыл бұрын
@@Pepcoding Sir KZbin par yaa Zoom, agr zoom par h toh link send kar dijiye!
@ajayjangid59683 жыл бұрын
Jai Hind sir... Your are doing ✌️✌️✌️
@Pepcoding3 жыл бұрын
Jai hind
@arpanbanejee51433 жыл бұрын
Sir, iska memoized version pls bata dijiye, sab jagah bottom up kie hua hian
@ajayjangid11643 жыл бұрын
Nice explanation👌
@pravinmudaliyar34214 жыл бұрын
Sir , isme backtracking kaha ho rha h! Kahi pe bhi backtrack code nhi likha hua ? Btw ... Your teaching is just amazing. Thankyou sir🙏
@Pepcoding4 жыл бұрын
beta, title misleading hai. recursion and backtracking ka group hai. kuch swaal sirf recursion ke hain.
@joyd66093 жыл бұрын
great explanation sir
@sudhanshukumar15584 жыл бұрын
It's time complexity is T=O(2^n)
@LegitGamer23453 жыл бұрын
n power n
@LegitGamer23453 жыл бұрын
n options n levels
@yatinarora12523 жыл бұрын
Its basically taking the length of string and cutting it by length of left substring so total will be n power n and space is basically of length of substring basically n times and calculating it by n times
@Sajju_012 жыл бұрын
It is only recursion not backtracking right??
@nilufaislam47684 жыл бұрын
Sir what is the time and space complexity? And can we use dp here to store the intermediate results and improve the time ?
@Pepcoding4 жыл бұрын
time complexity exponential. Yes we can use DP. That video will be posted soon.
@sharmamukul9384 жыл бұрын
I don't think this approach works for all possible cases. It works for cases when a word is of form str.substring(0,i+1) but fails when words are present in the form str.substring(i,j) ,i.e when words are present between the sentence and not necessarily at the start of sentence. Example: {"ou" ,"suyoypayul" ,"eim","otehzri"} "otehzriabeimabouabsuyoypayulabouab" In the above case, the above-discussed algorithm will not return all words present in the sentence (that are present in the dictionary).
@RahulMaurya-tc2wi4 жыл бұрын
yes,this approach will fail in this type of cases! Do you have another approach?
@LegitGamer23453 жыл бұрын
maybe what u are saying can be resolved by taking subsets of the string instead of prefixes
@yatinarora12523 жыл бұрын
Two pointer may help😐
@naitikverma65863 жыл бұрын
gfg pe to ispe AC aya
@deepakjumani64464 жыл бұрын
sir ek hi sentence m dictionary vaale array ke 1 hi word ko do baar use ke skte h kya?
@LegitGamer23453 жыл бұрын
yes
@nidhirathore72842 жыл бұрын
Thank you Sir 😄😄😄😄
@sandeeprajurs19943 жыл бұрын
just wanted to know how to prepare for ds and algos interview. Is it like we need to solve questions on all topics and in interview we just need to find the question belongs to which pattern that we have already solved...based on that we need to come up with solution rite?
@LegitGamer23453 жыл бұрын
yes sir
@ankitamehra50454 жыл бұрын
sir how to prepare for online tests..do we need to do competitive for that. under time pressure approach nahi anti dimaag main in online assessment
@Pepcoding4 жыл бұрын
beta competitive necessary nahi hai, beneficial hai. 90% of my students who did it, did without competitive.
@utkarshshrivastava36473 жыл бұрын
@@Pepcoding sir maximum offcampus coding rounds ke liye competitive strong hona chahiye na?
@mickyman7533 жыл бұрын
@@utkarshshrivastava3647 nhi ,mostly 3-4 companies hi hai jinke liye jaruri ai ,baaki mai dsa se hi ho jata hai
@ravikishores3 жыл бұрын
Will it work for string=abcd and dictionary={ab, abc, d}.. Solution is picking "ab" first , then it will only search for cd..
@Pepcoding3 жыл бұрын
Buddy, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.
@nidhirathore72842 жыл бұрын
It will work fined
@rupeshsharma92354 жыл бұрын
sir ,you are great
@Pepcoding4 жыл бұрын
Keep learning
@rahulbhatia30754 жыл бұрын
Superb explaination
@Pepcoding4 жыл бұрын
Glad you liked it
@satvrii Жыл бұрын
❤
@punitsharma44244 жыл бұрын
sir how many question is left in backtracking?
@Pepcoding4 жыл бұрын
total 50 hai level 2 mei, level 1 ke 30 ho chuke. level 2 ke takreeban 20 ho chuke. level 2 mei abhi 30 aur karenge. Inn 80 questions ko jisne ache se kar lia wo kam se kam recursion and backtracking mei kabhi kahin nahi fassega.
@punitsharma44244 жыл бұрын
Thank you sir
@mayur_madhwani033 жыл бұрын
code khud hi likh liya itna sahi samjhaya hai na sir jo question is topic se related nahi hai vo bhi ban jaate hai just because you teach how to think
@abheetsingh99384 жыл бұрын
the submission fails for this test case: "aaaaaaa" ["aaaa","aaa"]
@vishalm7844 жыл бұрын
It works...Please check your implementation
@siddhantkumar94923 жыл бұрын
@@vishalm784 It's not working,can you send your code
@shauncrasta6193 жыл бұрын
TLE de raha he leetcode pe...
@puskinmittal89564 жыл бұрын
sir how to use DP in it?
@Pepcoding4 жыл бұрын
Ye bhi aaega beta. DP mei aaega alag se
@tusharagarwal34754 жыл бұрын
Isme backtracking kha use hui hai
@vikkasmaheshwari8622 жыл бұрын
Jo ans me left string ka addtion krke pass kr rhe hai parameter me wo ek trh ka backtrack hai kyunki function call hone ke bad ans same wohi bn jaega sirf function ki call me left string add kiya hai. Agr isko alg ds me add krke pass krte to you can see easily how backtracking happening
@bikramjitdas26213 жыл бұрын
This code is returning me an empty string,can anyone help out? int helperdict(vector& dict, string left, int n) { for(int i = 0; i
@rohandevaki43492 жыл бұрын
we need solution which works on leetcode, not on pepcoding ,
@arpanbanejee51433 жыл бұрын
Can anyone help me with the memoization of this code? class Solution { private List solve(String s,Set seen,String op, List res){ if(s.length()==0){ res.add(op.trim()); return res; } for(int i=1;i
@CodeCraftWithVinayak4 жыл бұрын
submission me Kuch problem hai shayed, same code mene bar bar submit kiya pura test cases pass hua kabi kuch fail hua: Submission ID: 517616 (comple passed) 517614 (failed few ) same code hai likein
@ayushgoel95844 жыл бұрын
www.geeksforgeeks.org/magnet-puzzle-backtracking-9/ , sir isko bhi ek baar solvekara dijiyega , kaafi insight milegi isse, google has also asked variations of this question 3-4 times.
@Pepcoding4 жыл бұрын
hanji, it's a favourite with us as well. Aj he daalenge.