Detect Impossible Travel Between Consecutive Mailbox Sign-Ins

Last updated: November 29, 2026

Quick Overview

Given sign-in events of the form (user, timestamp, ip, latitude, longitude), report each pair of consecutive sign-ins for the same user whose implied travel speed exceeds a threshold such as 900 km/h, while suppressing obvious noise.

Abnormal Security
Coding & Algorithms
Software Engineer
Abnormal Security
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given sign-in events of the form (user, timestamp, ip, latitude, longitude), report each pair of consecutive sign-ins for the same user whose implied travel speed exceeds a threshold such as 900 km/h, while suppressing obvious noise.

Email account takeover protection at Abnormal looks at sign-in telemetry alongside mail behavior, and impossible travel is one of the clearest signals. The interviewer wants correct great-circle distance, per-user ordering, and judgment about noise sources like VPN egress and geo-IP error rather than a naive threshold.

What the Interviewer Expects
  • Groups events by user and sorts by timestamp
  • Uses haversine distance rather than Euclidean on lat/lon
  • Guards against division by zero for near-simultaneous events
  • Applies a minimum distance to ignore geo-IP jitter
  • Handles trusted IP ranges such as corporate VPN egress
  • States complexity and how it would run as a stream
Key Topics to Cover
haversine
sorting and grouping
account takeover
anomaly detection
streaming state
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you make this streaming with only the last event per user in memory?
  • Mobile carriers geolocate to a regional hub. How would you reduce those false positives?
  • How would you combine this with a suspicious inbox rule creation to raise confidence?
  • What if events arrive out of order by a few minutes?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input events may be unsorted and span many users. For each user, compare each sign-in with the previous one. Alert when distance is at least min_km and distance / elapsed exceeds max_kmh. Sign-i...

High-Level Design

Bucket events by user, sort each bucket by time, and walk consecutive pairs. Distance uses the haversine formula on a 6371 km sphere. Elapsed time is floored at one minute, so two logins in the same s...


Submit Your Answer
Markdown supported

Related Questions