Skip to content

Latest commit

 

History

History
10 lines (10 loc) · 548 Bytes

note0489.md

File metadata and controls

10 lines (10 loc) · 548 Bytes
  • Type: Search (dfs)
  • Approach:
    • Top-down dfs.
    • Use basic dfs backtrack thought but the question is a little bit tricky for recovering to its original state.
    • The original state includes its direction and cell postion.
    • Remember to backtrack whenever a move() takes because if robot.move() is True, it has to be move forward to another cell and it has to be recovered to the original state (cell, direction).
  • Complexity:
    • Time: O(n)
    • Space: O(n)