The Path Crossing problem asks whether a path described by a string of directions ('N','S','E','W') crosses itself — i.e., revisits a position it has already been at. This easy coding problem uses a hash set to track visited positions. The hash table and string interview pattern is demonstrated.
Yandex, Amazon, Google, and Adobe ask this as a quick screening problem testing coordinate tracking with a hash set. It validates that candidates can simulate movement, encode positions as hashable keys, and detect revisits.
Coordinate hash set. Start at (0,0). Add initial position to visited set. For each direction: update (x,y) based on direction. If (x,y) already in visited, return true. Add (x,y) to visited. Return false after processing all directions.
path="NES". Start at (0,0).
path="NESWW": (0,0)→(0,1)→(1,1)→(1,0)→(0,0)→(-1,0). At (0,0) again → true.
Path tracking with hash sets is a standard coordinate problem. Use tuples (x,y) as hash set keys. Always include the starting position. Direction mappings: N=(0,+1), S=(0,-1), E=(+1,0), W=(-1,0) — or any consistent convention. Practice similar problems: "robot on 2D grid," "walking path self-intersection," "spiral path tracking." All use the same coordinate-hash-set pattern.