Dsa
Graphs Dfs
Hard
Treasure Island Map
You have a map of an island represented as a 2D grid where 'S' is the start, 'T' is the treasure, 'W' are land, and 'O' are water. Write a program to determine if there exists a path from 'S' to 'T'. Paths can only move through 'W'. The grid will be terminated by 'END'.
Example:
Input:
SWWO
WWOW
OOOT
END
Output:
Yes
Key concepts
graphsdfsterritory
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now