Programmers / Shortest Path in Game Map
Problem
- Link
- Description
- Find the shortest path in a game map
- Type
- Brute Force / BFS
Solution 1
| |
- Description
- Use BFS for search
- While DFS can search all paths and then determine the shortest path, BFS doesn’t need to search all paths
- Time Complexity
- O(len(mapX) * len(mapY))
- Proportional to map size as it visits each cell once while searching for the path
- Space Complexity
- O(len(mapX) * len(mapY))
- Memory usage proportional to map size for function input