← All problemsSign in

Sam in the cave

Archaeologist Sam is inside a historical cave which is in the form of an N X M matrix. He has already researched about this cave and knows the complete map of the cave. Cave is divided into N X M blocks. Each block is either a path or a wall. The cave has only one terminal point, from where one can enter the cave or exit from the cave given by (Xe, Ye). Sam is currently at a point (Xi, Yi), where

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start