The Activity Participants coding problem asks you to query a database to find the names of activities that have neither the maximum nor the minimum number of participants. You are typically given a Friends table and an Activities table.
This Activity Participants interview question is frequently used by IBM to test a candidate's ability to handle outlier exclusion. In data analysis, you often need to remove the "best" and "worst" performers to see the average behavior, and this SQL problem mimics that real-world scenario perfectly.
This problem uses an Aggregation and Subquery interview pattern. You must:
MAX and MIN counts from those results.If 'Football' has 10 people, 'Eating' has 2 people, and 'Singing' has 5 people:
ORDER BY and OFFSET which doesn't work if there are ties at the top or bottom.When filtering based on aggregate limits, use IN or NOT IN with subqueries. It makes the logic explicit and handles ties automatically.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Find Longest Calls | Medium | Solve | |
| Active Businesses | Medium | Solve | |
| Active Users | Medium | Solve | |
| All People Report to the Given Manager | Medium | Solve | |
| All the Pairs With the Maximum Number of Common Followers | Medium | Solve |