Question: https://leetcode.com/problems/robot-room-cleaner Solution: https://leetcode.com/problems/robot-room-cleaner/discuss/139057/Very-easy-to-understand-Java-solution If you are mentally lazy, you read the solution and you say to yourself 'Yes, standard recursive DFS with backtracking, next!'. But if you try to trace how this solution works, you'll realize its subtleties: First subtlety: After it returns from 'backtracking' call, it does 2 left turns, move(), and 2 right turns to RESTORE its position to whatever the direction it ENTERED that last visit with, in order for it to CONTINUE searching for the remaining directions. Second subtlety: At every recursive call, it has an initial direction. And it'll try 4 right turns, which will allow it to COME BACK to its initial direction when it exists the particular call, so the previous function can RESUME with the SAME direction it entered with, and that function wil go on searching for remaining directions. None of those 2 subtleties are related to DFS or backtracking, but unique to this problem. But even given a solution, it is not trivial to observe these 2 points if you just glance through the solution and say to yourself 'Yea I get it'. Anyone came up with an ACCEPTED solution to this problem without looking at the discussion board, and is that solution similar to this one?
Do 2 Wongs make it right ? (Hashtag Chinese programmer)