HomeInterview QuestionsGiven a dataset containing session ID, timestamp, …

Given a dataset containing session ID, timestamp, and lane information, identify the exact timestamp where a lane change event occurred and ensure that the vehicle remained in the new lane for at least one second.

🟡 Medium Coding Junior level
1Times asked
Aug 2026Last seen
Aug 2026First seen

💡 Model Answer

To solve this problem, first sort the data by session ID and timestamp. Then iterate through each session’s records. For each consecutive pair of records, compare the lane values. If the lane changes, record the timestamp of the change. Next, look ahead in the same session to find the first record where the lane differs again. Compute the time difference between the change timestamp and the next different lane timestamp. If this difference is at least 1 second, the lane change event satisfies the requirement. Store or output the change timestamp. Complexity is O(n log n) for sorting and O(n) for the scan, so overall O(n log n). Edge cases include missing timestamps or duplicate entries; these can be handled by ignoring duplicates or interpolating missing data.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500