Given a string representing directions (e.g., 'N', 'S', 'E', 'W'), simulate walking on a 2D grid starting from (0,0). Return true if the path crosses itself — i.e., you visit any point more than once — otherwise return false
Sigiloso
I used a Set to track all visited positions. For each character in the string, I updated the current (x, y) coordinates accordingly and checked if the new position was already in the set. If yes – return true. If the loop completes – return false. I implemented it in Java and the logic worked correctly