BAE SYSTEMS Hiring | On-Campus OA (2022) | Path Crossing
Question · Posted Jun 2026
Problem Statement You are given a string path consisting of the characters 'N', 'S', 'E', and 'W', representing movements on a 2D plane starting from the origin (0,0). Determine whether the path crosses itself, i.e., whether the same coordinate is visited more than once. Example Input: path = "NESWW" Output: true Explanation: The path returns to a previously visited coordinate, so it crosses itself.
The full answer & interview discussion are available to premium members.
Log in Create a free account