Uber’s efficiency depends on "Batching" rides. Two trips are considered "Shareable" if they meet the following criteria:
Write a query to find all pairs of unique trip IDs that could have been shared.
| trip_id(INTEGER) | rider_id(INTEGER) | city_id(INTEGER) | pickup_time(TIMESTAMP) | dropoff_time(TIMESTAMP) |
|---|---|---|---|---|
| 101 | 1 | 1 | 2026-02-14 08:00:00 | 2026-02-14 08:30:00 |
| 102 | 2 | 1 | 2026-02-14 08:10:00 | 2026-02-14 08:40:00 |
| 103 | 3 | 1 | 2026-02-14 09:00:00 | 2026-02-14 09:15:00 |
| 104 | 4 | 2 | 2026-02-14 08:05:00 | 2026-02-14 08:25:00 |
| 105 | 5 | 1 | 2026-02-14 08:20:00 | 2026-02-14 08:50:00 |
| rider_id(INTEGER) | is_prime(BOOLEAN) |
|---|---|
| 1 | true |
| city_id(INTEGER) | city_name(VARCHAR) |
|---|---|
| 1 | San Francisco |
| trip_id_1(INTEGER) | trip_id_2(INTEGER) | city_id(INTEGER) | overlap_minutes(INTEGER) |
|---|---|---|---|
| 101 | 102 | 1 | 20 |
| 102 | 105 | 1 | 20 |
| 101 | 105 | 1 | 10 |