Source Code:https://thecodingsimplified.com/rat-maze-problem/
Solution:
- We'll solve it using DFS approach
- We'll take a solution matrix
- Rat moves down then right side
- If there's safe path, we mark value as 1 in Solution matrix
- If there's no path from a index, we need to backtrack, so we reset the value to 0 for that index
- At the last if rat reaches to x = N - 1 & y = N-1, it means we've a solution
- Now we've all path in solution matrix
Time Complexity: O(N * N)
Space Complexity: O(N * N)
CHECK OUT CODING SIMPLIFIED
https://www.youtube.com/codingsimplified
★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
https://www.youtube.com/codingsimplified?sub_confirmation=1
★☆★ Send us mail at: ★☆★
Email: [email protected]