Am I going correct in this Question?

Am I going correct in this Question?

Please tell if you find any Logical Mistake in this or any other error.

Question Pic I am attacthing

hello @cbcao263

ha bhai sahi ja rahe ho.

some optimisation->
a)map se badhiya ek 3d matrix bana lete given info store karne ke liye.
mat[N][M][5] size ki

b) agar ek path se true return ho gya hai to phir baaki mat check karo sidha true return kar do

1 Like

Okayy bro Thnx
Okayy
Map se krrha usse ek baar try krke submit krdu
College Assignment hain yeh isliye
Fr Matrix se bhi try krta hu

Vaise Map ka jyada fayda nhi hoga
Direct Access hojayega
But wo ton yaar Matrix mein bhi hojayega
Fayda kya hoga vaise To use Matrix than Map

2nd Krke dekhta hu

matrix thoda fast rahega map se

1 Like

Okayy
Kaafi shi rhega fir ton

bhai yeh kuch errors remove kiye
Yeh Scope ke kya errors derha

Iske liye Base Case mein return true ki jgah return false krdu
Chlega na?

nahi base case mein return true is rahega.

1 Like

check now->

ek visited array aur rakhna padega takki infinite circle mein na phase .

ek baar rat chases its cheese problem solve karo ,phir ye karna

1 Like

Rate chases its cheese
Same Problem nhi hai
Rate in a maze jaisi

Abhi dekha
Difference is usme ek print krwaana pdega

ND For that,
yaar mene Base Case mein ek baar print krwaadiya
Agar Multiple Print krwaane hain fir false krnaa pdega right?
Jaisa N Queen mein kiya tha

abhi ton Killed dikharha O/P with that I/P.

agar ek baar print karwana hai to true rakna hota hai , multiple ke liye false

1 Like

infinite recursion ki wajah se. isko solve karne ke liye visited array rakhni padegi aur.
isiliye bol raha hu ek bar rat chases its cheese revise kar lo

1 Like

Bhaiyeh ton direct isse hogya tha
bas 1 test case nhi pass kiya tha

Fir isme bhi Same Modifications lgaani pdegi kya
!down
!right waali

wo sol matrix isme bhi lagegi.

ha ye laga sakte ho thoda time kam lagega phir

1 Like

Ab shi hai?..

@cbcao263

ab dekho->

base case correct kiya hai , waha last cell ka index hona tha

1 Like

Hogya tha Bhai
Thanks a lot

Ab Kuch doubts clear krdo :smiley:
Yeh solved kyu liya
Jab mene element pehle hi i*n+j+1 se krliya tha
isliye solved kahe kiya

solved bus ye store kar raha hai ki current path tak hum kis kis cell se ho ke aaye hain.
isko hum use kar rahe hain taaki koi bhi cell ek sa jayda baar na visit ho path find ke dauran.
isiliye hum agar kisi cell be jaa rahe hai jaha sol[i][j] 1 hai to waha se hum false return kar rahe hai ,kyunki wo already hum pehle include kar chuke hain.
aur infinite cycle bhi avoid hoga

1 Like

Okayyy Bro
Thanks a lot

Bhut Acha smjhaadiya
Thanks a lot