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

Leetcode Problem 1132. Reported Posts II

1132. Reported Posts II

Leetcode Solutions

Calculating Average Daily Percentage of Removed Spam Posts

  1. Filter the Actions table to get records where extra is 'spam'.
  2. Remove duplicates from the filtered data based on action_date and post_id to ensure each spam report is counted once per day.
  3. Perform a left join with the Removals table on post_id to find out which reported spam posts were removed.
  4. Group the joined data by action_date and calculate two aggregates: the count of removed spam posts and the size of all reported spam posts.
  5. Calculate the daily percentage of removed spam posts by dividing the count of removed spam posts by the total reported spam posts for each day.
  6. Calculate the overall average of these daily percentages to get the final result.
  7. Round the result to two decimal places as required.
erDiagram
    Actions {
        int user_id
        int post_id
        date action_date
        enum action
        varchar extra
    }
    Removals {
        int post_id
        date remove_date
    }
    Actions }|--|| Removals : ""

Computing Average Daily Percentage of Removed Spam Reports Using Aggregation and Conditional Counting

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...