Knights Tour - Solution | Recursion | Data Structures and Algorithms in JAVA

  Рет қаралды 80,499

Pepcoding

Pepcoding

Күн бұрын

Пікірлер: 172
@pratyush__agarwal
@pratyush__agarwal 3 жыл бұрын
Very well explained. N queen question was the foundation stone of this question. The way you sequence all of the question is also very important and you are ace on it.❤️
@Pepcoding
@Pepcoding 3 жыл бұрын
Keep learning and keep loving Pepcoding😊
@snehaashishgupta1254
@snehaashishgupta1254 3 жыл бұрын
istg am able to register recursion only because of the ordering of recursion questions!
@pallavimeshram5491
@pallavimeshram5491 3 жыл бұрын
Finally I can say that I know recursion, Thank you so much for making this videos, I got stucked in recursion in past that's why I was not able to proceed with topics like dp, trees, graphs. But I am feeling confident now.
@AbhishekChaudhary-hl9kx
@AbhishekChaudhary-hl9kx 3 жыл бұрын
OMG, done from itself same approach after the dry run and recursion tree. thankyou very very much sir.
@pratyushtiwari103
@pratyushtiwari103 3 жыл бұрын
I was fearing from recursion but after watching your videos i'd say just one thing- maja aagya. Thank you sir for such an awesome playlist
@Pepcoding
@Pepcoding 3 жыл бұрын
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc
@KejriwalBhakt
@KejriwalBhakt 3 жыл бұрын
Abb yeh maza sabko do..
@ShreyasShirwadkar
@ShreyasShirwadkar 2 ай бұрын
Sir thank you for this recursion playlist. I was a complete beginner but now I have my basics cleared and can solve diff questions too! THANK YOU 🙏
@priyanshshukla5777
@priyanshshukla5777 3 жыл бұрын
Binge watching DSA season 1 (Foundation course ) Thank You Sir
@a_85_viveksinghyadav60
@a_85_viveksinghyadav60 2 жыл бұрын
Sir today I completed this series and I tried one question of subset using recursion , can't tell you how I feel after solving that by myself. Thanks a lot sir for this amazing series of recursion.
@yelp9359
@yelp9359 4 жыл бұрын
Phli baar itna maza aa raha hai sir recursion padhne me. 🤩🤩
@Pepcoding
@Pepcoding 4 жыл бұрын
Thank you. Please support by subscribing and pressing the bell notification. Also, it will be really helpful to share this in the college groups.
@yelp9359
@yelp9359 4 жыл бұрын
@@Pepcoding already done sir ☺️
@gauravgupta9477
@gauravgupta9477 4 жыл бұрын
Yeah....Now i intentionally write every possible code i could think of recursively. Maza to aa raha hai bhai.
@aashishgoyal1436
@aashishgoyal1436 4 жыл бұрын
Thank u so much sir. completed recursion playlist today. Really fantastic videos and explanations.
@Pepcoding
@Pepcoding 4 жыл бұрын
Wow. bhot badhiya. ab aage badhie, DP pe
@aashishgoyal1436
@aashishgoyal1436 4 жыл бұрын
@@Pepcoding sure Sir. Thanks a lot for ur guidance
@mayankverma714
@mayankverma714 3 жыл бұрын
Completed the Recursion in Backtracking ; Moving to DP. Thanks to sumeet sir.
@karlmaximum500
@karlmaximum500 4 жыл бұрын
Sir thank you for this. You are our savior in these uncertain times. Also when will you upload DSA and interview prep videos on KZbin?
@Pepcoding
@Pepcoding 4 жыл бұрын
Bass next month
@karlmaximum500
@karlmaximum500 4 жыл бұрын
@@Pepcoding Thank you so much.
@ShivamSinghMAITCSE
@ShivamSinghMAITCSE 4 жыл бұрын
@@Pepcoding sir singh in usa me kitta accha video banwaya sir aapne 😍😍
@potato-gi1xr
@potato-gi1xr 3 жыл бұрын
thank you so much sir for this Playlist. initially didn't wanted to watch basic recursion videos, since I already knew about them. But, I watched which made my concepts really good and solved the questions on NADOS. Now, I have solved all the questions in DSA level 1- Recursion and backtracking. thank you so much sir.🙏🙏🙏
@democratcobra
@democratcobra 2 жыл бұрын
Recursion was nightmare to me ...now i am loving it ..thank you Sumit sir...
@amanwadhwa5432
@amanwadhwa5432 10 ай бұрын
Now i am also confident about recursion Thanks sir
@bitqahdi6592
@bitqahdi6592 4 жыл бұрын
I enjoyed the entire playlist ! Thanks my best friend
@Pepcoding
@Pepcoding 4 жыл бұрын
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem. Keep learning and keep loving Pepcoding☺️
@bitqahdi6592
@bitqahdi6592 3 жыл бұрын
@@Pepcoding Sure Pepcoding is
@swatimaurya9405
@swatimaurya9405 3 жыл бұрын
thank you so much sir itne helpful content ka lea ajj recursion apki vejha se bhut ache se aya ha samjh.😊
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad it helped, for better experience, doubt support, career opportunities and well-organised content, visit - nados.pepcoding.com Don't forget to follow us on Instagram instagram.com/pepcoding/
@AnujRYadav
@AnujRYadav 3 жыл бұрын
Completed This Playlist 💗 Feeling Confident Thank You sir
@Pepcoding
@Pepcoding 3 жыл бұрын
Very good, keep it up and always feel confident beta.
@AnujRYadav
@AnujRYadav 3 жыл бұрын
@@Pepcoding Thank You So Much Sir
@abhisheksoti1115
@abhisheksoti1115 3 жыл бұрын
I express my sincere gratitude towards you Sumeet Sir. I know I could not attend regular classes since I am a 7 year experienced developer in the industry, but still wanted to say Thank you for teaching me so much. I would keep on learning, targeting to finish DSA level 1 this month, Kudos to Nados, great platform.
@Pepcoding
@Pepcoding 3 жыл бұрын
We are really glad that it was helpful for you. Stay tuned on NADOS and on our Instagram account.
@ParasVashishth_RV
@ParasVashishth_RV 3 жыл бұрын
Sir, recursion ke liye es playlist ke concepts enough h na, bcz ye vale last 10 ques. khud ban gaye the. plz reply
@Pepcoding
@Pepcoding 3 жыл бұрын
Enough to nh but basic idea de dege ye questions apko recursion ka baki abhi level-2 main bhi cover krege aur questions recursions k
@ParasVashishth_RV
@ParasVashishth_RV 3 жыл бұрын
@@Pepcoding ok sir Thanx
@mickyman753
@mickyman753 3 жыл бұрын
@@Pepcoding sir iske baad seedhe level 2 ka recursion chalu krdu kya ,mujhe basics atey hai dsa ke but sirf recursion aur advance ds main hi problem hai
@raj_kundalia
@raj_kundalia 2 жыл бұрын
Watched on 29 December, 2021, thanks for the video.
@ashwinnema06
@ashwinnema06 2 жыл бұрын
Nice explanation sir. I solved this question myself but I was not getting right answer. Then I saw your code in the video and I found that I missed one condition. Now I solved this question.
@Pepcoding
@Pepcoding 2 жыл бұрын
Great! For better experience and well organised content sign up on nados.io And for being updated follow us on Instagram instagram.com/pepcoding/
@nitinnegi862
@nitinnegi862 2 жыл бұрын
Thank you sir for this awesome series!!
@ShivamSinghMAITCSE
@ShivamSinghMAITCSE 4 жыл бұрын
sir singh in usa me kitta accha video banwaya sir aapne 😍😍
@Pepcoding
@Pepcoding 4 жыл бұрын
@anshshrivastava9107
@anshshrivastava9107 3 жыл бұрын
1:53 laaiye isko hum koshish karne ki koshish krte hain... XD real life recursion
@mickyman753
@mickyman753 3 жыл бұрын
hands down the playlist to understand recursion
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou beta! I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
@codeblooded6760
@codeblooded6760 3 жыл бұрын
Shouldnt it be chess[0].length for column instead of chess.length ?
@Pepcoding
@Pepcoding 3 жыл бұрын
Beta, both will work because n*n size h
@venkateshkalyan9429
@venkateshkalyan9429 10 ай бұрын
Sir , why didnt you mention any where in the video that , its a back tracking Algo ? am I missing something ?
@vanshdhiman366
@vanshdhiman366 4 жыл бұрын
Really great😁 kya samjhate ho sir SIR FLATTENING A LINKED LIST PRR EK VIDEO BANADO, SAMAJ NHI AA RHA
@Pepcoding
@Pepcoding 4 жыл бұрын
Thank you beta. Pkka bnegi video.
@sharuk3545
@sharuk3545 3 жыл бұрын
woww you convet the hard problem in the easy problem
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou beta! I am glad you liked it. I also hope that you are watching till the end and trying to understand the what, how, and especially why of the problem. If you like our efforts, will you like to review us here - g.page/Pepcoding/review?rc
@harshitkaushik4144
@harshitkaushik4144 4 жыл бұрын
Always there for your support sir.
@Pepcoding
@Pepcoding 4 жыл бұрын
Thanks Man😍🙏🏼 Much appreciated😘
@ShivamSinghMAITCSE
@ShivamSinghMAITCSE 4 жыл бұрын
Sir please ek aur playlist jisme wo success stories wale baache apna question discuss krte hai unke solution wale video ko us new playlist me add kr dijiye sir " interview previous asked questions "
@Pepcoding
@Pepcoding 4 жыл бұрын
yar, kar to denge. par companies ka non-disclosure agreement hota hai apne staff ke sath. to bache discourage karte hain ajkal. So we will make a list and do a mock interview including those questions.
@pranshulkharniwal8146
@pranshulkharniwal8146 3 жыл бұрын
@@Pepcoding sir list ban gai kya??
@SugamMaheshwari
@SugamMaheshwari 4 жыл бұрын
Sir , Why doesn't it give answer when we don't follow the clockwise pattern of moves ?????
@Pepcoding
@Pepcoding 4 жыл бұрын
beta code wo bhi sahi hoga. Par online judge jo hai wo to text check kar sakta hai. Uske liye ek order lena jaruri tha. Maine clockwise le liya
@ShivamSinghMAITCSE
@ShivamSinghMAITCSE 4 жыл бұрын
Bhai aapka answer jo hai wo ek expected answer ke saath seedha seedha check hota hai agar usme ek space ka bhi difference hoga toh wo wrong code bata dega . Its as simple as that pr code wo bhi sahi hai aapka
@prateek2159
@prateek2159 2 жыл бұрын
Sir this solution results in time limit exceeded on naados, gfg and codechef's compilers. Please look into it. And sir you didn't explain warnsdorff's algorithm for this question.
@Pepcoding
@Pepcoding 2 жыл бұрын
Thankyou for the feedback. will look into it and for better experience and well curated content visit nados.io
@nknidhi321
@nknidhi321 3 жыл бұрын
Thank you so much..🔥🔥
@vikasjoshi7236
@vikasjoshi7236 3 жыл бұрын
sir ye video graph ki playlist m kyu h ?
@AryanSharma-dh4fb
@AryanSharma-dh4fb 2 жыл бұрын
warnsdorff's algorithm ki wajah se shadad, but you will have to google that algorith.
@vivekkumar-ct7rb
@vivekkumar-ct7rb 3 жыл бұрын
Sir please reply karna, Pehle time complexity karoo ya dp and greedy kyuki pepcoding ke site jab click karta hu to donno har baar change ho jataaa hai, matlab kabhi time complexity ooper aata hai to kabhi DP.
@tusharchamp488
@tusharchamp488 3 жыл бұрын
Sir SOlution Submit nahi ho rha ye wala IDE par kya kre...???
@vrindasharma4035
@vrindasharma4035 2 жыл бұрын
Finally, completed the recursion...... So, happyyyyyyyyyyyyy!!!!!!!!
@kashba
@kashba 2 жыл бұрын
abhi kitna karliya aapne?
@jyotiprasadchatterjee8707
@jyotiprasadchatterjee8707 3 жыл бұрын
can i learn these from pep code from class 10? im intersted a lot in computer
@himanshuchhikara4918
@himanshuchhikara4918 4 жыл бұрын
thankyou sir for making videos like this
@Pepcoding
@Pepcoding 4 жыл бұрын
Thank you very much!! share as much as you can
@sairajdas6692
@sairajdas6692 3 жыл бұрын
Sir I think we should also check if (chess[r][c] != 0) after first if. May be that's why it is not accepting for some test cases.
@deepakagrawal7687
@deepakagrawal7687 2 жыл бұрын
it will not enter into block where displayboard is called for 5*5 matrix. please tell the input for which it will enter the if condition. also please tell why for 5*5 or your input as well blank is output
@HarshKumar-nh6be
@HarshKumar-nh6be 4 жыл бұрын
Great teaching❤
@Pepcoding
@Pepcoding 4 жыл бұрын
Glad it was helpful!
@035asadali8
@035asadali8 2 жыл бұрын
i just realise i complete the playlist and learn all basics of recursion and backtracking in playlist
@csgirl6895
@csgirl6895 3 жыл бұрын
clean and easy code. Thank you so much sir
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad it helped
@navaneethakrishnak9384
@navaneethakrishnak9384 3 жыл бұрын
hello sir actually here the order of writinf recusrsion function maters but why?like if we write 30th line on 31 and 31st on 30 we are getting error
@ManishTiwari-ge1wc
@ManishTiwari-ge1wc 4 жыл бұрын
Great Explanation
@Pepcoding
@Pepcoding 4 жыл бұрын
Thankyou beta, I am glad you liked it. I also hope that you are watching till end. If you like our efforts, will you like to write a few words about us here - (www.quora.com/Which-is-the-best-institute-for-coding-in-Delhi)
@harshitkaushik4144
@harshitkaushik4144 4 жыл бұрын
manneeessshhhh bhaiiiiii
@sriramkrishnamurthy4473
@sriramkrishnamurthy4473 3 жыл бұрын
Bhai from which video is backtracking actually started in this playlist apart from level 2 level 1 ke playlist me kaunse video se backtracking start hota hai ?
@NituPandelPCECS
@NituPandelPCECS Жыл бұрын
Thank you So much🙇
@peeyushpachaori4626
@peeyushpachaori4626 4 жыл бұрын
Thanks for putting it through, it's great to watch and learn :). For the Knights tour problem, it seems an extension of the Hamiltonian problem, however, I noticed that the code doesn't check for already visited cells. Is it something not required for this?
@Pepcoding
@Pepcoding 4 жыл бұрын
Yes, it is hamiltonian only. Visited nahi chaie kyunki chess board mei he daal dia value, jisse pta chal jata hai ki cell visited hai. If you like my efforts, I request a review g.page/Pepcoding/review?rc
@rahulranjan7567
@rahulranjan7567 4 жыл бұрын
Visited check ho rahi hai base case mein...chess[i][j]>0 hogi to return ho rahi that means we are not going urther down the call. agar hum yeh check nahi karenge toh vauge values aayenge in cells
@AmanKumar-jt9zb
@AmanKumar-jt9zb 3 жыл бұрын
Thankyou so much for your solution videos sir i have missed the actual line of this code that leads to backtracking and it lies in the base case i was setting the last position but while returning i was not setting it to 0 again just in the base case and because of that i was getting wrong answer but now i know what mistake i have dont just because of your solution video. Thankyou again.
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊
@dheerajkhushalani2619
@dheerajkhushalani2619 3 жыл бұрын
can i display on moves greater than 25 condition.. it can be more easy to understand?? if move >25{ display(chess) return; }
@letsdoeverythinginoneweek9398
@letsdoeverythinginoneweek9398 3 жыл бұрын
sir jaise ki hamna display kardiya apna board ko toh usa hatana jaruri ha kya matlab display toh kar diya hamna apna output
@parthsaraswat9744
@parthsaraswat9744 4 жыл бұрын
Sir yaha recursion ke basics complete hue hai..backtracking ke thode level question ki videos dekhe ya fir DP par aa jae
@abhinavkohli4293
@abhinavkohli4293 Жыл бұрын
pecoding's online judge is not working
@nivealokhande2153
@nivealokhande2153 Жыл бұрын
bnd kr dia hai 😢
@sakshiaggarwal6199
@sakshiaggarwal6199 3 жыл бұрын
Thank You so much sir!!
@hemantsingh-zo3iw
@hemantsingh-zo3iw 4 жыл бұрын
Sir, you are awesome
@Pepcoding
@Pepcoding 4 жыл бұрын
So nice of you
@nikhilkumarjamwal5322
@nikhilkumarjamwal5322 2 жыл бұрын
Good one.👍 I did not get that last part of else if condition. Can someone tell me why did we use that condition and how our knight came to last position of table???
@kashba
@kashba 2 жыл бұрын
n queens aur flood fill dekho questions pehle ye smajh aajayega
@loserfruit9663
@loserfruit9663 3 жыл бұрын
Feel aa gayi sirr
@neerajyadav9412
@neerajyadav9412 4 жыл бұрын
sir ab DP kre yaa Time and Space complexity
@K_EC_piyushkumarsingh
@K_EC_piyushkumarsingh 2 жыл бұрын
Is it necessary to make chess[][]=0 in base case.?
@Pepcoding
@Pepcoding 2 жыл бұрын
For better insight, visit nados.io, post your doubts, community will help you out there.
@loserfruit9663
@loserfruit9663 3 жыл бұрын
Dhanyawad
@sahilgupta9378
@sahilgupta9378 3 жыл бұрын
whats the time complexity????
@Pepcoding
@Pepcoding 3 жыл бұрын
Beta, 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.
@sahilgupta9378
@sahilgupta9378 3 жыл бұрын
@@Pepcoding thanks sir, for sure:)
@sahilgupta9378
@sahilgupta9378 3 жыл бұрын
@@Pepcoding Thankyou sir, I posted in telegram and in a minute someone helped, great community
@ritikshrivastava9442
@ritikshrivastava9442 3 жыл бұрын
what is the time complexity of this man?
@dark_techyy
@dark_techyy 3 жыл бұрын
Ye undo.wali bat smj me ni ayi...hme ek bar visit kiye hue cell ko Dobara visit nhi krna h na...to unvisit q krre h last me?🤔🤔🤔
@jigarlove2113
@jigarlove2113 3 жыл бұрын
because hme sare answers chahiye n. jitna bhi possible ho sakta hai
@divyanshbarar3840
@divyanshbarar3840 2 жыл бұрын
again best ..................... :,*
@rishabhgoyal2835
@rishabhgoyal2835 4 жыл бұрын
this is showing in graphs of level 1 , plz update it
@Pepcoding
@Pepcoding 4 жыл бұрын
Ok ji.
@taruvarmittal1484
@taruvarmittal1484 3 жыл бұрын
sir, aapne move reset kyu kiya ? I mean saari calls ke baad chess[row][column] = 0 kyu kardiya vaapis ?
@Pepcoding
@Pepcoding 3 жыл бұрын
Beta, 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.
@taruvarmittal1484
@taruvarmittal1484 3 жыл бұрын
@@Pepcoding ok thankyou sir
@Otmar_Schloetterlein
@Otmar_Schloetterlein 3 жыл бұрын
i have found this way and the best we can go from field 64 to field 1 so are this a solution for all fields
@Otmar_Schloetterlein
@Otmar_Schloetterlein 11 ай бұрын
Lösung zum Rösselsprungproblem aus dem Schach von jedem beliebigen Anfangsfeld 11 24 47 34 01 14 49 36 46 33 12 25 48 35 02 15 23 10 45 64 13 26 37 50 44 57 32 29 60 63 16 03 09 22 61 58 27 30 51 38 56 43 28 31 62 59 04 17 21 08 41 54 19 06 39 52 42 55 20 07 40 53 18 05
@omda6197
@omda6197 3 жыл бұрын
sir gfg aur leetcode kaise use kaRe aapki videos k saath-2
@kiyotaka721
@kiyotaka721 4 жыл бұрын
sir is there any way instead of writing 8 recursive call we write the call in a for loop?
@Pepcoding
@Pepcoding 4 жыл бұрын
this is more convenient. yes there is a way. using two d arrays.
@kiyotaka721
@kiyotaka721 4 жыл бұрын
@@Pepcoding ok sir and thank u for this amazing content
@rahulranjan7567
@rahulranjan7567 4 жыл бұрын
Gruji is there a position on chess board jisse knights travel krr le puri board ko? I want to see the output for a successful case.Thanks guruji
@Pepcoding
@Pepcoding 4 жыл бұрын
Beta, 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.
@sudhindrashenoy7992
@sudhindrashenoy7992 3 жыл бұрын
Hello Sir.. I kindly request you to create videos on sliding window and two pointers coding patterns
@Pepcoding
@Pepcoding 3 жыл бұрын
Hanji beta, ek bari jo agenda main questions h vo complete kr le, then ye sb cheeze bhi cover kr lenge
@harshpandey7605
@harshpandey7605 4 жыл бұрын
Sir chess length*chesslength ke liye alg se conition kyun likhi hai please bata dijiye
@Pepcoding
@Pepcoding 4 жыл бұрын
u have to fill the board with each move of the knight and in order to stop the recursion we should know how many total boxes are to filled so as total number of boxes in 2-d matrix is defined as n*m so base case would be applied on that chess length*chess length
@harshpandey7605
@harshpandey7605 4 жыл бұрын
@@Pepcoding Thank you very much
@vaibhavagarwal9055
@vaibhavagarwal9055 Жыл бұрын
solution is wrong. not working
@arijitgoswami7570
@arijitgoswami7570 3 жыл бұрын
Sir sare move chalne ke bad chess[r][c]=0 kyu krre ho wo samajh me nhi aya..
@Pepcoding
@Pepcoding 3 жыл бұрын
Beta, 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.
@rohitmeena1772
@rohitmeena1772 3 жыл бұрын
bhai saare moves ko level 1 maan, isme apne backtrack karte hue humne saare options explore kar liye hai isliye ab wapas initial value set karna padega na. Ek baar dry run karke dekho paper me.
@venkateshvenky2880
@venkateshvenky2880 4 жыл бұрын
Thanks sir...♥️
@Pepcoding
@Pepcoding 4 жыл бұрын
Most welcome
@arshadmanxoori07
@arshadmanxoori07 3 жыл бұрын
Sir Recursion ke baad.. DP karuu ya Basic DS?
@yashodeepdhas8408
@yashodeepdhas8408 3 жыл бұрын
Same doubt bhai
@arshadmanxoori07
@arshadmanxoori07 3 жыл бұрын
@@yashodeepdhas8408 vroo i think DP krna hi sahi rhega
@nivealokhande2153
@nivealokhande2153 Жыл бұрын
@@arshadmanxoori07 bhai basic phle krna hota hai, fir recursion, fir dp
@arshadmanxoori07
@arshadmanxoori07 Жыл бұрын
@@nivealokhande2153 2 saal ho gye bhai.. ab to sb kr liya
@nivealokhande2153
@nivealokhande2153 Жыл бұрын
@@arshadmanxoori07 shi hai😂, mai hi late aaya idhr lgta hai
@SCRIPTSAG
@SCRIPTSAG 4 жыл бұрын
Sir aapke sare question samgh aa ja rhe hai but sir aap standard formate me return ker diya kre values ko en Sare problma beacuse on geeks of geeks and leetcode we faced many problems
@Pepcoding
@Pepcoding 4 жыл бұрын
ok ji
@AshishGusain17
@AshishGusain17 3 жыл бұрын
thanks
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad to know, that you love the explanation, for better experience and precisely arranged videos. Visit - nados.pepcoding.com and sign up to NADOS. Don't forget to follow us on Instagram instagram.com/pepcoding/
@JohnWick-kh7ow
@JohnWick-kh7ow 3 жыл бұрын
Sir aise video ab kyo nhi banate. ab adhe ghante ke video hote h maja nhi aata. Videos short banaya karo achha response milega.
@whynesspower
@whynesspower 2 жыл бұрын
3:54 "Tu mujhe marwayegi" ended up being true, faced the same question in microsoft interview HAHAHA
@nknidhi321
@nknidhi321 3 жыл бұрын
🔥❤️
@dayamalik6025
@dayamalik6025 4 жыл бұрын
Hello chachu your Aryan
@Pepcoding
@Pepcoding 4 жыл бұрын
i love you aryan
@sasikalaramesh8751
@sasikalaramesh8751 Жыл бұрын
please explain in english..:(
@anjneykumarsingh4461
@anjneykumarsingh4461 4 жыл бұрын
Isko dry krne m mja ayega
@Pepcoding
@Pepcoding 4 жыл бұрын
Padhte rahie
@anjneykumarsingh4461
@anjneykumarsingh4461 4 жыл бұрын
Ji guruji
@pratikjha2742
@pratikjha2742 3 жыл бұрын
knight is ghoda
@Pepcoding
@Pepcoding 3 жыл бұрын
Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
@nivealokhande2153
@nivealokhande2153 Жыл бұрын
@@abacas2175 😂😂
@smitjoshi4513
@smitjoshi4513 3 жыл бұрын
Can anyone tell me what's wrong in the following code, as I am getting a blank output. import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int[][] chess = new int[n][n]; int row = scn.nextInt(); int col = scn.nextInt(); printKnightsTour(chess,row,col,0); } public static void printKnightsTour(int[][] chess, int row, int col, int upcomingMove) { if(row=chess.length||chess[row][col] >0){ return; } if(upcomingMove == chess.length * chess.length){ chess[row][col] = upcomingMove; displayBoard(chess); chess[row][col] = 0; return; } chess[row][col] = upcomingMove; printKnightsTour(chess,row-2,col+1,upcomingMove+1); printKnightsTour(chess,row-1,col+2,upcomingMove+1); printKnightsTour(chess,row+1,col+2,upcomingMove+1); printKnightsTour(chess,row+2,col+1,upcomingMove+1); printKnightsTour(chess,row+2,col-1,upcomingMove+1); printKnightsTour(chess,row+1,col-2,upcomingMove+1); printKnightsTour(chess,row-1,col-2,upcomingMove+1); printKnightsTour(chess,row-2,col-1,upcomingMove+1); chess[row][col] = 0; } public static void displayBoard(int[][] chess){ for(int i = 0; i < chess.length; i++){ for(int j = 0; j < chess[0].length; j++){ System.out.print(chess[i][j] + " "); } System.out.println(); } System.out.println(); } }
@hodex5763
@hodex5763 3 жыл бұрын
in the main function when you call printKnightsTour you have to pass the move as 1, since you are passing 0 there all the moves in the matrix even when visited by the knight get decremented by one so it never reaches the bas case where it has to execute the displayBoard function. So your code doesn't print anything, if you want to stick to your code in the base case you can write, if(upcomingMove + 1 == chess.length * chess.length)
@TechyEra
@TechyEra Жыл бұрын
@@hodex5763 I converted that code in php, it's working great. But my own code going into infinite loop. To me both codes are the same. working code: function printKnightsTour(&$chess, $row, $col, $upcomingMove) { if ($row < 0 || $col < 0 || $row >= count($chess) || $col >= count($chess) || $chess[$row][$col] != ".") { return; } if ($upcomingMove == ( (count($chess) * count($chess))-1 )) { $chess[$row][$col] = $upcomingMove; displayBoard($chess); exit(); } $chess[$row][$col] = $upcomingMove; printKnightsTour($chess, $row - 2, $col + 1, $upcomingMove + 1); printKnightsTour($chess, $row - 1, $col + 2, $upcomingMove + 1); printKnightsTour($chess, $row + 1, $col + 2, $upcomingMove + 1); printKnightsTour($chess, $row + 2, $col + 1, $upcomingMove + 1); printKnightsTour($chess, $row + 2, $col - 1, $upcomingMove + 1); printKnightsTour($chess, $row + 1, $col - 2, $upcomingMove + 1); printKnightsTour($chess, $row - 1, $col - 2, $upcomingMove + 1); printKnightsTour($chess, $row - 2, $col - 1, $upcomingMove + 1); $chess[$row][$col] = "."; } not working code function printKnightsTourNotWorking(&$chess, $row, $col, $upcomingMove) { // if ($row < 0 || $col < 0 || $row >= count($chess) || $col >= count($chess) || $chess[$row][$col] != ".") { // return; // } if ($upcomingMove == ( (count($chess) * count($chess))-1 )) { $chess[$row][$col] = $upcomingMove; displayBoard($chess); exit(); $chess[$row][$col] = 0; return; } $chess[$row][$col] = $upcomingMove; $directions = [[2,1],[2,-1],[1,-2],[-1,-2],[1,2],[-1,2],[-2,-1],[-2,1]]; for($k=0; $k= count($chess) || $dj >= count($chess) || $chess[$di][$dj] != ".") { continue; } else{ printKnightsTour($chess, $di, $dj, $upcomingMove + 1); } } // printKnightsTour($chess, $row - 2, $col + 1, $upcomingMove + 1); // printKnightsTour($chess, $row - 1, $col + 2, $upcomingMove + 1); // printKnightsTour($chess, $row + 1, $col + 2, $upcomingMove + 1); // printKnightsTour($chess, $row + 2, $col + 1, $upcomingMove + 1); // printKnightsTour($chess, $row + 2, $col - 1, $upcomingMove + 1); // printKnightsTour($chess, $row + 1, $col - 2, $upcomingMove + 1); // printKnightsTour($chess, $row - 1, $col - 2, $upcomingMove + 1); // printKnightsTour($chess, $row - 2, $col - 1, $upcomingMove + 1); $chess[$row][$col] = "."; }
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 31 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 31 МЛН
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
Knight's Tour - Numberphile
4:51
Numberphile
Рет қаралды 959 М.
The Backtracking Blueprint: The Legendary 3 Keys To Backtracking Algorithms
13:44
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
PQ #4 - N Queens Problem using Backtracking | Easiest Solution REVEALED !!
28:51
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 31 МЛН