Practice Path Crossing
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path. Return true if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false otherwise.
Source: Path Crossing on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
path = "NES"
false
# Example 2
path = "NESWW"
true
Constraints
Related LeetCode Problems
Practice more problems similar to Path Crossing.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.