1633. Percentage of Users Attended a Contest LeetCode Solution
In this guide, you will get 1633. Percentage of Users Attended a Contest LeetCode Solution with the best time and space complexity. The solution to Percentage of Users Attended a Contest 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
- Percentage of Users Attended a Contest solution in C++
- Percentage of Users Attended a Contest solution in Java
- Percentage of Users Attended a Contest solution in Python
- Additional Resources
Problem Statement of Percentage of Users Attended a Contest
Table: Users
+————-+———+
| Column Name | Type |
+————-+———+
| user_id | int |
| user_name | varchar |
+————-+———+
user_id is the primary key (column with unique values) for this table.
Each row of this table contains the name and the id of a user.
Table: Register
+————-+———+
| Column Name | Type |
+————-+———+
| contest_id | int |
| user_id | int |
+————-+———+
(contest_id, user_id) is the primary key (combination of columns with unique values) for this table.
Each row of this table contains the id of a user and the contest they registered into.
Write a solution to find the percentage of the users registered in each contest rounded to two decimals.
Return the result table ordered by percentage in descending order. In case of a tie, order it by contest_id in ascending 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
1633. Percentage of Users Attended a Contest LeetCode Solution in C++
SELECT
contest_id,
ROUND(
COUNT(user_id) * 100 / (
SELECT COUNT(*)
FROM Users
),
) AS percentage
FROM Register
GROUP BY 1
ORDER BY percentage DESC, contest_id;
/* code provided by PROGIEZ */
1633. Percentage of Users Attended a Contest LeetCode Solution in Java
N/A
// code provided by PROGIEZ
1633. Percentage of Users Attended a Contest 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.