Path Crossing
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A walker starts at the origin (0, 0) of a grid and follows the moves in path, one character per unit step: 'N' moves up (y + 1), 'S' down (y - 1), 'E' right (x + 1), and 'W' left (x - 1).
Return true if the walker ever stands on a point it has already visited (including the starting point), and false otherwise.
Examples
Constraints
- 1 <= path.length <= 10^4
- path[i] is one of 'N', 'S', 'E', 'W'
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.