262. Trips and Users LeetCode Solution
In this guide, you will get 262. Trips and Users LeetCode Solution with the best time and space complexity. The solution to Trips and Users problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Trips and Users solution in C++
- Trips and Users solution in Java
- Trips and Users solution in Python
- Additional Resources

Problem Statement of Trips and Users
Table: Trips
+————-+———-+
| Column Name | Type |
+————-+———-+
| id | int |
| client_id | int |
| driver_id | int |
| city_id | int |
| status | enum |
| request_at | varchar |
+————-+———-+
id is the primary key (column with unique values) for this table.
The table holds all taxi trips. Each trip has a unique id, while client_id and driver_id are foreign keys to the users_id at the Users table.
Status is an ENUM (category) type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’).
Table: Users
+————-+———-+
| Column Name | Type |
+————-+———-+
| users_id | int |
| banned | enum |
| role | enum |
+————-+———-+
users_id is the primary key (column with unique values) for this table.
The table holds all users. Each user has a unique users_id, and role is an ENUM type of (‘client’, ‘driver’, ‘partner’).
banned is an ENUM (category) type of (‘Yes’, ‘No’).
The cancellation rate is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.
Write a solution to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between “2013-10-01” and “2013-10-03”. Round Cancellation Rate to two decimal points.
Return the result table in any order.
The result format is in the following example.
Example not found
Constraints not found
Complexity Analysis
- Time Complexity: Google AdSense
- Space Complexity: Google Analytics
262. Trips and Users LeetCode Solution in C++
SELECT
Trips.request_at AS Day,
ROUND(SUM(Trips.status != 'completed') / COUNT(*), 2) AS 'Cancellation Rate'
FROM Trips
INNER JOIN Users AS Clients
ON (Trips.client_id = Clients.users_id)
INNER JOIN Users AS Drivers
ON (Trips.driver_id = Drivers.users_id)
WHERE Clients.banned = 'No'
AND Drivers.banned = 'No'
AND Trips.request_at BETWEEN '2013-10-01' AND '2013-10-03'
GROUP BY 1;
/* code provided by PROGIEZ */
262. Trips and Users LeetCode Solution in Java
N/A
// code provided by PROGIEZ
262. Trips and Users LeetCode Solution in Python
N/A
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.