Path Finder #1: can you reach the exit?
Task
You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). Return true if you can reach position [N-1, N-1] or false otherwise.
- Empty positions are marked
.
. - Walls are marked
W
. - Start and exit positions are empty in all test cases.
Solution
Test
Path Finder #2: shortest path
Task
You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). Return the minimal number of steps to exit position [N-1, N-1] if it is possible to reach the exit from the starting position. Otherwise, return -1.
- Empty positions are marked
.
. - Walls are marked
W
. - Start and exit positions are guaranteed to be empty in all test cases.
Solution
Test
Path Finder #3: the Alpinist
Task
You are at start location [0, 0] in mountain area of NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). Return minimal number of climb rounds to target location [N-1, N-1]. Number of climb rounds between adjacent locations is defined as difference of location altitudes (ascending or descending).
- Location altitude is defined as an integer number (0-9).
Solution
- It can be solved Dijkstra.
- But past posted Dijkstra need
Priority Queue
. - So you should use
SortedList
instead of.
Test
Path Finder #4: : where are you?
Task
- Hint is in Test Code
- It means that r is turn right, l is turn left, R is turn right twice, and L is turn left twice