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

Leetcode Problem 1355. Activity Participants

1355. Activity Participants

Leetcode Solutions

Using RANK() to Identify Non-Extreme Activities

  1. Use a SELECT statement to count the number of participants for each activity from the Friends table and group by activity.
  2. Apply the RANK() window function over the count in ascending order to get the rank_asc for each activity.
  3. Apply the RANK() window function over the count in descending order to get the rank_desc for each activity.
  4. Use a subquery or common table expression (CTE) to select activities where both rank_asc and rank_desc are not equal to 1.
  5. Return the activity names that meet the above condition.
erDiagram
    Friends ||--o{ Activities : has
    Friends {
        int id PK
        varchar name
        varchar activity
    }
    Activities {
        int id PK
        varchar name
    }

Using NOT IN with Aggregated Subqueries

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...
bugfree Icon
OR