Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Overlapping Anomalous Coordinates

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Find Overlapping Anomalous Coordinates. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Zoox engineers want to identify locations where anomalous path-planning adjustments affected multiple autonomous vehicles. Because GPS readings can differ slightly, treat coordinates rounded to four decimal places as the same location.

Write a PostgreSQL query to identify overlapping anomalous coordinates from the provided tables.

Requirements

  1. Include only path-planning events marked as anomalous with non-null latitude and longitude.
  2. Join events to known Zoox autonomous vehicles and group coordinates after rounding latitude and longitude to four decimal places.
  3. Return locations associated with at least two distinct vehicles, along with the number of distinct vehicles, anomalous adjustments, and a comma-separated list of vehicle IDs.
  4. Order results by rounded latitude and longitude.

Schema

autonomous_vehicles
ColumnTypeDescription
vehicle_idPKINTUnique identifier for an autonomous vehicle
vehicle_nameVARCHAR(80)Internal Zoox vehicle name
fleet_statusVARCHAR(30)Current operating status of the vehicle
path_planning_events
ColumnTypeDescription
event_idPKINTUnique path-planning event identifier
vehicle_idINTVehicle associated with the event
event_timeTIMESTAMPTime when the planning adjustment occurred
latitudeNUMERIC(9,6)Recorded latitude
longitudeNUMERIC(9,6)Recorded longitude
anomaly_flagBOOLEANWhether the event was classified as anomalous
adjustment_typeVARCHAR(40)Type of path-planning adjustment
adjustment_metersNUMERIC(6,2)Magnitude of the path adjustment in meters
Tablesautonomous_vehiclespath_planning_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results