1211. Queries Quality and Percentage LeetCode Solution

In this guide, you will get 1211. Queries Quality and Percentage LeetCode Solution with the best time and space complexity. The solution to Queries Quality and Percentage 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. Queries Quality and Percentage solution in C++
  4. Queries Quality and Percentage solution in Java
  5. Queries Quality and Percentage solution in Python
  6. Additional Resources
1211. Queries Quality and Percentage LeetCode Solution image

Problem Statement of Queries Quality and Percentage

Table: Queries

+————-+———+
| Column Name | Type |
+————-+———+
| query_name | varchar |
| result | varchar |
| position | int |
| rating | int |
+————-+———+
This table may have duplicate rows.
This table contains information collected from some queries on a database.
The position column has a value from 1 to 500.
The rating column has a value from 1 to 5. Query with rating less than 3 is a poor query.

We define query quality as:

The average of the ratio between query rating and its position.

We also define poor query percentage as:

The percentage of all queries with rating less than 3.

Write a solution to find each query_name, the quality and poor_query_percentage.
Both quality and poor_query_percentage should be rounded to 2 decimal places.
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

1211. Queries Quality and Percentage LeetCode Solution in C++

SELECT
  query_name,
  ROUND(AVG(rating / position), 2) AS quality,
  ROUND(AVG(rating < 3) * 100, 2) AS poor_query_percentage
FROM Queries
GROUP BY 1;
/* code provided by PROGIEZ */

1211. Queries Quality and Percentage LeetCode Solution in Java

N/A
// code provided by PROGIEZ

1211. Queries Quality and Percentage LeetCode Solution in Python

N/A
# code by PROGIEZ

Additional Resources

See also  1171. Remove Zero Sum Consecutive Nodes from Linked List LeetCode Solution

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