1934. Confirmation Rate LeetCode Solution

In this guide, you will get 1934. Confirmation Rate LeetCode Solution with the best time and space complexity. The solution to Confirmation Rate 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

  1. Problem Statement
  2. Complexity Analysis
  3. Confirmation Rate solution in C++
  4. Confirmation Rate solution in Java
  5. Confirmation Rate solution in Python
  6. Additional Resources
1934. Confirmation Rate LeetCode Solution image

Problem Statement of Confirmation Rate

Table: Signups

+—————-+———-+
| Column Name | Type |
+—————-+———-+
| user_id | int |
| time_stamp | datetime |
+—————-+———-+
user_id is the column of unique values for this table.
Each row contains information about the signup time for the user with ID user_id.

Table: Confirmations

+—————-+———-+
| Column Name | Type |
+—————-+———-+
| user_id | int |
| time_stamp | datetime |
| action | ENUM |
+—————-+———-+
(user_id, time_stamp) is the primary key (combination of columns with unique values) for this table.
user_id is a foreign key (reference column) to the Signups table.
action is an ENUM (category) of the type (‘confirmed’, ‘timeout’)
Each row of this table indicates that the user with ID user_id requested a confirmation message at time_stamp and that confirmation message was either confirmed (‘confirmed’) or expired without confirming (‘timeout’).

The confirmation rate of a user is the number of ‘confirmed’ messages divided by the total number of requested confirmation messages. The confirmation rate of a user that did not request any confirmation messages is 0. Round the confirmation rate to two decimal places.
Write a solution to find the confirmation rate of each user.
Return the result table in any order.
The result format is in the following example.

See also  2134. Minimum Swaps to Group All 1's Together II LeetCode Solution

Example not found

Constraints not found

Complexity Analysis

  • Time Complexity: Google AdSense
  • Space Complexity: Google Analytics

1934. Confirmation Rate LeetCode Solution in C++

SELECT
  Signups.user_id,
  IFNULL(ROUND(AVG(Confirmations.action = 'confirmed'), 2), 0) AS confirmation_rate
FROM Signups
LEFT JOIN Confirmations
  USING (user_id)
GROUP BY 1;
/* code provided by PROGIEZ */

1934. Confirmation Rate LeetCode Solution in Java

N/A
// code provided by PROGIEZ

1934. Confirmation Rate LeetCode Solution in Python

N/A
# code by PROGIEZ

Additional Resources

Happy Coding! Keep following PROGIEZ for more updates and solutions.