Skip to content

Commit be51a50

Browse files
committed
Added README.md file for Confirmation Rate
1 parent bf27e31 commit be51a50

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

2087-confirmation-rate/README.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<h2><a href="https://leetcode.com/problems/confirmation-rate">Confirmation Rate</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>Table: <code>Signups</code></p>
2+
3+
<pre>
4+
+----------------+----------+
5+
| Column Name | Type |
6+
+----------------+----------+
7+
| user_id | int |
8+
| time_stamp | datetime |
9+
+----------------+----------+
10+
user_id is the column of unique values for this table.
11+
Each row contains information about the signup time for the user with ID user_id.
12+
</pre>
13+
14+
<p>&nbsp;</p>
15+
16+
<p>Table: <code>Confirmations</code></p>
17+
18+
<pre>
19+
+----------------+----------+
20+
| Column Name | Type |
21+
+----------------+----------+
22+
| user_id | int |
23+
| time_stamp | datetime |
24+
| action | ENUM |
25+
+----------------+----------+
26+
(user_id, time_stamp) is the primary key (combination of columns with unique values) for this table.
27+
user_id is a foreign key (reference column) to the Signups table.
28+
action is an ENUM (category) of the type (&#39;confirmed&#39;, &#39;timeout&#39;)
29+
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 (&#39;confirmed&#39;) or expired without confirming (&#39;timeout&#39;).
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
34+
<p>The <strong>confirmation rate</strong> of a user is the number of <code>&#39;confirmed&#39;</code> messages divided by the total number of requested confirmation messages. The confirmation rate of a user that did not request any confirmation messages is <code>0</code>. Round the confirmation rate to <strong>two decimal</strong> places.</p>
35+
36+
<p>Write a solution to find the <strong>confirmation rate</strong> of each user.</p>
37+
38+
<p>Return the result table in <strong>any order</strong>.</p>
39+
40+
<p>The result format is in the following example.</p>
41+
42+
<p>&nbsp;</p>
43+
<p><strong class="example">Example 1:</strong></p>
44+
45+
<pre>
46+
<strong>Input:</strong>
47+
Signups table:
48+
+---------+---------------------+
49+
| user_id | time_stamp |
50+
+---------+---------------------+
51+
| 3 | 2020-03-21 10:16:13 |
52+
| 7 | 2020-01-04 13:57:59 |
53+
| 2 | 2020-07-29 23:09:44 |
54+
| 6 | 2020-12-09 10:39:37 |
55+
+---------+---------------------+
56+
Confirmations table:
57+
+---------+---------------------+-----------+
58+
| user_id | time_stamp | action |
59+
+---------+---------------------+-----------+
60+
| 3 | 2021-01-06 03:30:46 | timeout |
61+
| 3 | 2021-07-14 14:00:00 | timeout |
62+
| 7 | 2021-06-12 11:57:29 | confirmed |
63+
| 7 | 2021-06-13 12:58:28 | confirmed |
64+
| 7 | 2021-06-14 13:59:27 | confirmed |
65+
| 2 | 2021-01-22 00:00:00 | confirmed |
66+
| 2 | 2021-02-28 23:59:59 | timeout |
67+
+---------+---------------------+-----------+
68+
<strong>Output:</strong>
69+
+---------+-------------------+
70+
| user_id | confirmation_rate |
71+
+---------+-------------------+
72+
| 6 | 0.00 |
73+
| 3 | 0.00 |
74+
| 7 | 1.00 |
75+
| 2 | 0.50 |
76+
+---------+-------------------+
77+
<strong>Explanation:</strong>
78+
User 6 did not request any confirmation messages. The confirmation rate is 0.
79+
User 3 made 2 requests and both timed out. The confirmation rate is 0.
80+
User 7 made 3 requests and all were confirmed. The confirmation rate is 1.
81+
User 2 made 2 requests where one was confirmed and the other timed out. The confirmation rate is 1 / 2 = 0.5.
82+
</pre>

0 commit comments

Comments
 (0)