bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 578. Get Highest Answer Rate Question

578. Get Highest Answer Rate Question

Leetcode Solutions

Calculating Answer Rate and Ordering Results

  1. Group the records by question_id to calculate metrics per question.
  2. Count the number of times each question was answered using COUNT(answer_id).
  3. Count the number of times each question was shown using COUNT(CASE WHEN action = 'show' THEN 1 ELSE NULL END).
  4. Calculate the answer rate by dividing the count of answers by the count of shows.
  5. Order the results by answer rate in descending order to get the highest rate first.
  6. For questions with the same answer rate, order by question_id in ascending order to get the smallest question_id.
  7. Limit the results to 1 row to get the question with the highest answer rate.

erDiagram
    SurveyLog {
        int id
        ENUM action
        int question_id
        int answer_id
        int q_num
        int timestamp
    }

Using Average of Indicators to Calculate Answer Rate

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...