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

Leetcode Problem 601. Human Traffic of Stadium

601. Human Traffic of Stadium

Leetcode Solutions

Approach: Using Window Functions

  1. Use a CTE to select all records with people >= 100.
  2. In the CTE, use LEAD() and LAG() to get the id of the next two and previous two rows.
  3. In the main query, select distinct records from the CTE where the id is part of a sequence of three or more consecutive ids.
  4. Order the final result by visit_date.

erDiagram
    Stadium {
        int id
        date visit_date
        int people
    }

Approach: Using Self-Join

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...