Lecture 82: Rat in Maze Problem || Backtracking Day 1 || C++ Placement Series

  Рет қаралды 142,417

CodeHelp - by Babbar

CodeHelp - by Babbar

Күн бұрын

In this Video, we are going to learn about Backtracking in C++ and Questions
There is a lot to learn, Keep in mind “ Mnn bhot karega k chor yrr apne se nahi hoga ya maza nahi aara, Just ask 1 question “ Why I started ? “
[For 20% Discount ] Visit Coding Ninjas: bit.ly/3cfdKTe
Discord Server Link: / discord
Course Flow: whimsical.com/...
Notes Link: drive.google.c...
Slides Link: drive.google.c...
Code Links: github.com/lov...
Questions Links:
Rat in Maze Problem: www.codingninj...
Do provide you feedback in the comments, we are going to make it best collectively.
Connect with me here:
Instagram: / lovebabbar1
Twitter: / lovebabbar3
Telegram Group Link: Love Babbar CODE HELP
telegram.me/lo...
My Editor: www.instagram....
Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.
#DSABusted #LoveBabbar

Пікірлер: 175
@pranavmahendra3423
@pranavmahendra3423 2 жыл бұрын
Too much informative blessed to have a teacher like you😇
@kshitijbajpai9264
@kshitijbajpai9264 5 ай бұрын
Time complexity should be 3^(n^2) and not 4^(n^2) because we will not have a choice to go in direction from where we have come to that cell. Good Explanation!! Nice Series
@amitkumarsahu4729
@amitkumarsahu4729 2 жыл бұрын
Thank you bhaiya🥰 May God bless you❤ All the dreams come true What you are doing for us is speechless. We cannot thank you by words. 😘😘😘
@imshivendra
@imshivendra 2 жыл бұрын
Bro he is making crores per months Hatsoff yo him. he belongs from a simple middle class family but now he is making crores. His hard work and dedication leads him to get success in Life.
@thesleepycapy
@thesleepycapy Жыл бұрын
Instead of keeping a visited array, we can simply put arr[x][y] = 0 and reset it to one while backtracking
@modiashish1775
@modiashish1775 Жыл бұрын
Bhai to Pata kaise chalega ki wahan 1 Tha ya 0
@sushantshelte4694
@sushantshelte4694 Жыл бұрын
If it is visited that means it was 1 earlier.
@shibainu7500
@shibainu7500 Жыл бұрын
Nice
@IkramShaikh-ih6qe
@IkramShaikh-ih6qe Жыл бұрын
Teacher ho to Love Babbar bhaiya jaisa ho.....❤❤
@ShakibAhmad-jg5nk
@ShakibAhmad-jg5nk 4 ай бұрын
doosri baar ye sum solve karke maza agya aap ke saath
@vijeas4679
@vijeas4679 2 жыл бұрын
Thank u bhaiya for consistent again . we trust u
@harshitchaubey8274
@harshitchaubey8274 2 жыл бұрын
17 March course khatam hone wala tha Ab 17 April bhi nikal gya... Plz complete this course fast bhaiya 🙏
@anmolkumar01
@anmolkumar01 9 ай бұрын
bhaiya , i think the visited array should not be passed by reference because the visited node or box of one path can also be used by another path so there should be a unique visited array for each path so that it does not bother another path in case of 1 1 1 1 1 1 1 1 1 suppose i am going DDRR in one path but there will be a path RDLDRR and if lower row is already visited for first path so it would bother second path
@anshumansharma1069
@anshumansharma1069 2 жыл бұрын
bestest way to learn DSA❤️😘😍💐🙏🏻🙇🏻‍♂️
@Harsh_rai_29
@Harsh_rai_29 Жыл бұрын
Video number 90 ❤️🔥
@UzairKhan-qd3xu
@UzairKhan-qd3xu Жыл бұрын
// optimization of if-if cascade by using loop const vector posDir = {{1, 0}, {0, -1}, {0, 1}, {-1, 0}}; const vector moves = {'D', 'L', 'R', 'U'}; for (int i = 0; i < 4; ++i) { int newX = x + posDir[i].first; int newY = y + posDir[i].second; if (isValidMove(newX, newY, arr, visited, n)) { path.push_back(moves[i]); solve(newX, newY, arr, n, ans, visited, path); path.pop_back(); } }
@vishalgarna4580
@vishalgarna4580 Жыл бұрын
Great explanation sir 🎉🎉 thanks for all efforts are doing for ours 🙏☺️
@mansoorrr9167
@mansoorrr9167 Жыл бұрын
Love bhaiyya is an emotion, Sacchi mein bol raha hun itna accha kon padata hein bhai time nikaal ke ❤You will be a mark of my success bhaiyya, thank you soo much! 💫
@prashantbirajdar9271
@prashantbirajdar9271 2 жыл бұрын
thanks sir this was very easy way to solve the rat in maze problem...backtracking ka funda ekdum jabardast tarike se samaj aya ...love u sirr....
@KACodes
@KACodes 2 жыл бұрын
Bas bhaiya ....aise hi laate raho badhiya badhiya Let's crack it 😂
@vortexdeo4545
@vortexdeo4545 2 жыл бұрын
Nice, last video me iske baare me soch hi rha tha jab all possible matching words print ho the the. Wapas ake idhar kabhi waps aake udhar
@mr.himanshu4299
@mr.himanshu4299 2 жыл бұрын
aaiye apka swagat hai babbar bhai
@artandcraftworld38
@artandcraftworld38 2 жыл бұрын
ek number explaination bhaiya mjaa aa gya backtracking me.
@rachit_joshi
@rachit_joshi 7 ай бұрын
Thank You So Much BHRATA SHREE !!!!!!!
@amishapandey6875
@amishapandey6875 Жыл бұрын
You explain so well bhaiya!
@arpitsharma7246
@arpitsharma7246 2 жыл бұрын
this detail explaining is very awesome.
@ankitsaha675
@ankitsaha675 2 жыл бұрын
Kya baat hain bhaiya itna jaldi lecture
@samihabanu4044
@samihabanu4044 2 жыл бұрын
Keep it up bhaiya I no u wl never let us down consistentcy++++++++++++
@sahilanand4715
@sahilanand4715 2 жыл бұрын
Inko unicorn banwao yaar. Bahot honest insaan hai bhai apna.
@adapaavinash28
@adapaavinash28 Жыл бұрын
homework solution int dr[4]={-1,+1,0,0}; int dc[4]={0,0,-1,+1}; vector dir{'U','D','L','R'}; bool isValid(int r ,int c,int n,vector &vis,vector &m){ if(r>=0 && c>=0 && r
@iteself_me
@iteself_me Жыл бұрын
143 ✅completed 👍Liked 3:00
@jaydwarkadhish959
@jaydwarkadhish959 2 жыл бұрын
Sir amazing video super duper video
@unknownuser6143
@unknownuser6143 2 жыл бұрын
Great video. With great explanation... thanks babar.
@theraunak1466
@theraunak1466 Жыл бұрын
thank you bhaiya the course is very helpful
@mohitmail85
@mohitmail85 Жыл бұрын
Great explanation, Thank you
@mohitaggarwal2251
@mohitaggarwal2251 Жыл бұрын
Amazing❤❤
@shaileshsathe9779
@shaileshsathe9779 2 жыл бұрын
Very informative and nicely explained. Is it possible for you to post the Java code also with each video
@ranudhanotiya9363
@ranudhanotiya9363 Жыл бұрын
Thank you so much bhaiya for providing good content and for your efforts
@BornHubisLive
@BornHubisLive 2 жыл бұрын
Thanks a lot ....Bhaiya !!
@KumarDinesh-zw2vq
@KumarDinesh-zw2vq Жыл бұрын
Thank you very much sir!!
@govindnair3135
@govindnair3135 2 жыл бұрын
Love you bhaiyya ❤️
@Anmol-h8z
@Anmol-h8z 6 ай бұрын
we don' t need visted array we can mark that node as 0 when we reach that block
@ShubhamKumar-rh3dz
@ShubhamKumar-rh3dz Жыл бұрын
28:06 invalid initialisation jo aa rha solve function me ..wo kaise gya
@bhupendersingh2604
@bhupendersingh2604 2 жыл бұрын
good explanation Thanks Babbar.
@AryanKumar-un1ri
@AryanKumar-un1ri 2 жыл бұрын
Bhaiya , plzz complete this course within this month.
@paras_jain1312
@paras_jain1312 2 жыл бұрын
Complete hua??
@praash.
@praash. 2 жыл бұрын
Yes bhai rat in maze problem kara di hai map se apne
@utsavkumar6048
@utsavkumar6048 2 жыл бұрын
bhaiya mst samajh mein aya
@bite091_jamee7
@bite091_jamee7 2 жыл бұрын
present sirji
@Oroniislam-l6o
@Oroniislam-l6o 2 жыл бұрын
Thanks a lot vaia for consistent
@dhairya4176
@dhairya4176 2 жыл бұрын
Thanku bhaiya for this valuable content
@sahilchhabra2391
@sahilchhabra2391 2 жыл бұрын
thank you bhaiya, well explained!
@BhaiRayyanKiDuniya
@BhaiRayyanKiDuniya 2 жыл бұрын
ThanQ
@TechUprise-by-Jyoti
@TechUprise-by-Jyoti 2 жыл бұрын
Thank you bhaiya😇
@BhaiRayyanKiDuniya
@BhaiRayyanKiDuniya 2 жыл бұрын
May God Bless Y
@muskanpreetkaur5652
@muskanpreetkaur5652 Жыл бұрын
very very nice video..........maza++;
@ShivamGupta-qh8go
@ShivamGupta-qh8go 2 жыл бұрын
can we do it using dynamic programming
@MukeshKumar-fz3sw
@MukeshKumar-fz3sw 2 жыл бұрын
mza ++ , samajh aa gya ++
@DivyaAgarwal158
@DivyaAgarwal158 2 жыл бұрын
Sir this solution is giving runtime error on gfg
@KratosProton
@KratosProton 2 жыл бұрын
Great explaination
@063himanshumishra4
@063himanshumishra4 2 жыл бұрын
Bhaiya moj kr diii
@jitendrakumar-vv8ho
@jitendrakumar-vv8ho 6 ай бұрын
while backtracking how the string is getting emptied can anyone explain?
@sagnikmodak4178
@sagnikmodak4178 Жыл бұрын
thanks sir
@nishankdeep3084
@nishankdeep3084 2 жыл бұрын
thank you
@akankshapandey8316
@akankshapandey8316 2 жыл бұрын
Thanku sir ❤
@memorybyshubhammanitripath4368
@memorybyshubhammanitripath4368 2 жыл бұрын
Maja aaya 😁😁 Code link update kar do 😁😁😁😁😁
@sakshisingh5664
@sakshisingh5664 2 жыл бұрын
What does it mean "vector visited (n, vector(n,0));"
@sakshisingh5664
@sakshisingh5664 2 жыл бұрын
"visited (n, vector(n,0));"
@sakshisingh5664
@sakshisingh5664 2 жыл бұрын
I searched everywhere but I didn't find sufficient solution
@user-og1qm9ql7j
@user-og1qm9ql7j 2 жыл бұрын
Visited is a n-sized vector of n-sized vectors, with each smaller vector that is inside visited, has all its elements = 0. Basically, visited is a matrix of size n x n.
@BhaiRayyanKiDuniya
@BhaiRayyanKiDuniya 2 жыл бұрын
#Peace&&Blessings
@skchoudhary4122
@skchoudhary4122 2 жыл бұрын
🔥🔥🔥
@focus.placement5589
@focus.placement5589 2 жыл бұрын
thankss bhaiya
@Mainak908
@Mainak908 2 жыл бұрын
at 21:11 is that vector return type declared? I didn't understand at all...pls anyone clarify this
@Jaga6657
@Jaga6657 2 жыл бұрын
we are initializing vector (x,y) x represent size ,y represent value
@mdmesbahurrahman7311
@mdmesbahurrahman7311 2 жыл бұрын
I can solve codeforces div 2 -> (A) in contest regular, but can not solve B in contest. Now is this effictive for me to avoid solving A and start with problem B in contest ?
@suyashp
@suyashp 2 жыл бұрын
practice problems in the difficulty range 1000-1300 from problemset and you will improve.
@The_Shubham_Soni
@The_Shubham_Soni Жыл бұрын
Nice
@shresthkaushik6636
@shresthkaushik6636 Жыл бұрын
🙏🙏
@nishanthedaoo8937
@nishanthedaoo8937 2 жыл бұрын
Hello sir Can you reopen the registration ?
@keshavgambhir9894
@keshavgambhir9894 2 жыл бұрын
Present bhaiya
@anuptewary3016
@anuptewary3016 2 жыл бұрын
Swaad+++❤️
@mohdkonain6592
@mohdkonain6592 2 жыл бұрын
Consistency is back
@yashzawar7938
@yashzawar7938 2 жыл бұрын
did not understand the syntax of visited array/vector!!
@smanivesh
@smanivesh 2 жыл бұрын
BHAIYAA... CODE GIT PE UPLOAD KR DIJIYE PLEASE!!
@Profnegi
@Profnegi Жыл бұрын
hello didi apki placement hui kahi pr??
@smanivesh
@smanivesh Жыл бұрын
@@Profnegi haanji ho gyi😃
@Profnegi
@Profnegi Жыл бұрын
@@smanivesh on which company? 🥳 and didi pls guide me how I can grab an internship. (Confused++)
@smanivesh
@smanivesh Жыл бұрын
@@Profnegi I got placed in PWC as well as Comviva. For internship, you can approach different person from different companies and ask for the process of selection for internship. You can also approach HRs directly.
@Profnegi
@Profnegi Жыл бұрын
@@smanivesh thx.. 😇
@asktostranger8296
@asktostranger8296 2 жыл бұрын
Bahi consistency nahi rukni chaiye 😌🙏
@prathamesh2906
@prathamesh2906 2 жыл бұрын
Thanks for vidro
@360-prajwalkandalkar6
@360-prajwalkandalkar6 2 жыл бұрын
Thay you bro
@yashsingh7375
@yashsingh7375 Жыл бұрын
koi please " vector > visited(n, vector(n,0)); " ye wala statement samjha do please
@subhranilsaha4305
@subhranilsaha4305 Жыл бұрын
iska matlab visited matrix main 'n' number of rows hain and har ek row main ek bool vector hain jo 'n' number of zeros se initialized hain. Basically ye isliye likha gya hain taki for loop ka use na karna pare visited matrix ko initialize karne ke liye.
@RajKumar-vq1nm
@RajKumar-vq1nm 2 жыл бұрын
❤️
@gaming_zoid6159
@gaming_zoid6159 Жыл бұрын
Please anyone clear my doubt, Is the provided solution is simple recursion not backtracking?
@muhammadsuleman8936
@muhammadsuleman8936 Жыл бұрын
When the recursion unwinds it will remove the last character since its called backtracking
@RavindraKumar-bw6gi
@RavindraKumar-bw6gi Жыл бұрын
Can anyone explain me why we are not removing last character of Path while backtracking😢
@vamshigudimalla1013
@vamshigudimalla1013 Жыл бұрын
yeah you are right . we need to remove the char added when we are moving in the direction. this code fails on gfg site. we need to modify the code to remove the char added after recursive call
@suryapratap2219
@suryapratap2219 8 ай бұрын
but humne jo path hai vo by refrenvce nhi bheja simpl bheja hai to hur recursive call ke liye ek alag path banta hai aur usmein ussi specific call ke waqt jo path directions hote hn vhi rehte hn to bottom se backtrack karte vaqt unhen nikalne ki kya zaroorat
@adarshsharma3686
@adarshsharma3686 2 жыл бұрын
Approx aur kitne lecture bache honge is coarse me ?
@whatsnext7778
@whatsnext7778 2 жыл бұрын
40 +
@Winnerloser12
@Winnerloser12 2 жыл бұрын
60
@mohitchauhan7514
@mohitchauhan7514 2 жыл бұрын
😎
@sauravdhar1696
@sauravdhar1696 2 жыл бұрын
I'm in trees but I will start backtracking from today simultaneously
@praash.
@praash. 2 жыл бұрын
Can you interested in pair programming?
@sauravdhar1696
@sauravdhar1696 2 жыл бұрын
@@praash. main 8th sem mein hu bhaai 🙂🥲
@praash.
@praash. 2 жыл бұрын
@@sauravdhar1696 bhai pair programming krni h sem se kya fark padta h
@sauravdhar1696
@sauravdhar1696 2 жыл бұрын
@@praash. I mean I'm running out of time ...so ab bhaag rha hu bhaai tezi se bas to cover up things I don't think 2 log mein wo speed maintain hoga
@sauravdhar1696
@sauravdhar1696 2 жыл бұрын
@@praash. tum batao kitna padh liya hai ab tak?
@govindnair3135
@govindnair3135 2 жыл бұрын
😘😘😘😘😘😘
@pokigamerop
@pokigamerop Жыл бұрын
last test case :)
@aniketambat6334
@aniketambat6334 Жыл бұрын
Understand++
@someshsangwan5302
@someshsangwan5302 2 жыл бұрын
Bhaiya graph or Dp start kr do please jldi se
@code-beguru
@code-beguru Жыл бұрын
Couldn't get idea how to implement those 4 conditions with a for loop. Anyone has done this?
@sourabhbindal774
@sourabhbindal774 Жыл бұрын
Yes here is the code #include bool isSafe(int newx, int newy, vector< vector < bool>>& vis, vector >& arr, int n){ if(newx >=0 && newx < n && newy >= 0 && newy < n && vis[newx][newy] != 1 && arr[newx][newy] == 1){ return true; } return false; } void solve(int x, int y, string path, vector < vector < int >> &arr, vector< vector < bool>>& vis, int n, vector& ans){ //base case if(x == n-1 && y == n-1){ ans.push_back(path); } //4 movement //D L R U vis[x][y] = 1; //4 operations will make array int opx[4], opy[4]; char ch[4]; opx[0] = x+1; opy[0] = y; ch[0] = 'D'; //D opx[1] = x; opy[1] = y-1; ch[1] = 'L'; //L opx[2] = x; opy[2] = y+1; ch[2] = 'R'; //R opx[3] = x-1; opy[3] = y; ch[3] = 'U'; //U for(int i=0 ; i searchMaze(vector < vector < int >> & arr, int n) { // Write your code here. vector ans; vector vis(n, vector(n, false));; string path = ""; if(arr[0][0] == 0){ return ans; } solve(0, 0, path, arr, vis, n, ans); return ans; }
@iutkarshmehta
@iutkarshmehta 2 жыл бұрын
Attendence marked🙏🏻
@yashji6989
@yashji6989 Жыл бұрын
Abhi TK bahut hard lg rha tha par Ab nhi lgta
@Oroniislam-l6o
@Oroniislam-l6o 2 жыл бұрын
Consistently ++++++++++++
@mainaksen5064
@mainaksen5064 9 ай бұрын
20:00
@yashwantmishra9109
@yashwantmishra9109 2 жыл бұрын
Ye wala qs to phele karwaya tha bhaiya Vdo repeat ho gaya
@arshdeep011
@arshdeep011 2 жыл бұрын
Ma recursion se sida yaha a geya hu
@vannamnguyen5074
@vannamnguyen5074 Жыл бұрын
i think vid should have subtitle ,tks
@Ankitnsk178
@Ankitnsk178 7 ай бұрын
UnderStood++
@praveennemagoudar3442
@praveennemagoudar3442 Жыл бұрын
// HOME WORK class Solution{ public: string dir = "DLRU"; vector dx{+1,0,0,-1}; vector dy{0,-1,+1,0}; bool isSafe(int x, int y,vector &arr, vector &vis, int size) { if( x>=0 && x=0 && y
@abhishekgamer6097
@abhishekgamer6097 2 жыл бұрын
Present
Lecture 83: N-Queen Problem || Backtracking Day 2 || C++ Placement Series
31:04
CodeHelp - by Babbar
Рет қаралды 127 М.
Lecture40: Rat in a Maze Problem || C++ Placement Course 2022
37:31
CodeHelp - by Babbar
Рет қаралды 222 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
L19. Rat in A Maze | Backtracking
25:10
take U forward
Рет қаралды 234 М.
Backtracking Introduction + Maze Problems - Theory + Code + Tips
1:28:10
Kunal Kushwaha
Рет қаралды 224 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 258 М.
Как наука победила религию
17:02
Rat in a Maze Problem | Backtracking
32:45
Apna College
Рет қаралды 27 М.
Lecture 81: Implement a Phone Directory Using Trie || C++ Placement Series
27:04
The Backtracking Blueprint: The Legendary 3 Keys To Backtracking Algorithms
13:44
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН