Skip to content

Practice Confirmation Rate

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1934
LeetCode Problem

Confirmation Rate

Problem Statement

Tables: Signups(user_id INT, time_stamp DATETIME); Confirmations(user_id INT, time_stamp DATETIME, action ENUM). Signups.user_id is unique. Confirmations has key (user_id, time_stamp) and references Signups; action is confirmed or timeout. Return user_id and confirmation_rate for every signup. Divide the number of confirmed requests by all confirmation requests for that user, rounding to two decimals. Return 0 for users who made no request. Output order is unrestricted.

Source: Confirmation Rate on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
Signups table: +---------+---------------------+ | user_id | time_stamp          | +---------+---------------------+ | 3       | 2020-03-21 10:16:13 | | 7       | 2020-01-04 13:57:59 | | 2       | 2020-07-29 23:09:44 | | 6       | 2020-12-09 10:39:37 | +---------+---------------------+ Confirmations table: +---------+---------------------+-----------+ | user_id | time_stamp          | action    | +---------+---------------------+-----------+ | 3       | 2021-01-06 03:30:46 | timeout   | | 3       | 2021-07-14 14:00:00 | timeout   | | 7       | 2021-06-12 11:57:29 | confirmed | | 7       | 2021-06-13 12:58:28 | confirmed | | 7       | 2021-06-14 13:59:27 | confirmed | | 2       | 2021-01-22 00:00:00 | confirmed | | 2       | 2021-02-28 23:59:59 | timeout   | +---------+---------------------+-----------+
Output
+---------+-------------------+ | user_id | confirmation_rate | +---------+-------------------+ | 6       | 0.00              | | 3       | 0.00              | | 7       | 1.00              | | 2       | 0.50              | +---------+-------------------+

Related LeetCode Problems

Practice more problems similar to Confirmation Rate.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.