Self Crossing
A hard-tier problem at 32% community acceptance, tagged with Array, Math, Geometry. Reported in interviews at Zomato and 0 others.
Self Crossing is a hard geometry problem that's asked at Zomato. You're given a sequence of line lengths representing a path, and you need to detect if the path crosses itself. The acceptance rate sits at 32%, which means most people either miss the geometric insight or get tangled in edge cases. The trick isn't brute force collision detection. It's recognizing that a line can only cross one of the three previous lines, which cuts the problem down to pure math. If you hit this live and blank on the pattern, StealthCoder surfaces the solution invisible to the proctor.
Companies that ask "Self Crossing"
Self Crossing is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe core insight is that when drawing lines in sequence, a new line i can only intersect with line i-3, i-4, or i-5. Lines i-1 and i-2 are adjacent to the endpoint you're drawing from, and anything older than i-5 is too far away geometrically. Most candidates try to check all pairs or simulate the entire path, which is slow and error-prone. The real solution uses math to determine if two line segments intersect based on their endpoints and directions. You need to handle the geometry correctly: when does a horizontal line cross a vertical one, and what are the boundary conditions. Zomato probably uses this to filter for candidates who can reason about coordinate geometry under pressure. StealthCoder is your safety net if the geometric logic slips your mind mid-assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Self Crossing recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Self Crossing interview FAQ
Why is Self Crossing acceptance rate so low at 32%?+
Most candidates either try to check all line pairs (overkill) or get stuck on the geometric math. The real trick is proving that only three previous lines matter, then implementing segment intersection correctly. It's not algorithmically hard, it's a pattern recognition and geometry puzzle.
Is this problem still asked at Zomato?+
Zomato is in the input data as the company asking this problem. It's a geometry screening problem, so if you're interviewing there, this pattern is worth knowing cold. It tests whether you can think in coordinates and handle edge cases.
What's the most common mistake candidates make?+
Trying to build a full 2D grid or checking all previous lines for intersection. The mistake is not realizing that only lines i-3, i-4, and i-5 can possibly cross line i. Once you know that, the math becomes tractable.
How does Self Crossing relate to the Array and Math topics?+
You iterate through an array of lengths (Array), but you solve it with coordinate geometry and line intersection math (Math). Geometry is implicit. It's a hybrid problem that looks like array work but lives in the math space.
Do I need to implement full 2D geometry or is there a shortcut?+
There's a mathematical shortcut using inequalities on the line lengths and positions. You don't draw the grid. You prove algebraically when a crossing occurs by checking conditions on four consecutive lines. That's what separates the 32% who pass from everyone else.
Want the actual problem statement? View "Self Crossing" on LeetCode →