601. Human Traffic of Stadium LeetCode Solution
In this guide, you will get 601. Human Traffic of Stadium LeetCode Solution with the best time and space complexity. The solution to Human Traffic of Stadium problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Human Traffic of Stadium solution in C++
- Human Traffic of Stadium solution in Java
- Human Traffic of Stadium solution in Python
- Additional Resources

Problem Statement of Human Traffic of Stadium
Table: Stadium
+—————+———+
| Column Name | Type |
+—————+———+
| id | int |
| visit_date | date |
| people | int |
+—————+———+
visit_date is the column with unique values for this table.
Each row of this table contains the visit date and visit id to the stadium with the number of people during the visit.
As the id increases, the date increases as well.
Write a solution to display the records with three or more rows with consecutive id’s, and the number of people is greater than or equal to 100 for each.
Return the result table ordered by visit_date in ascending order.
The result format is in the following example.
Example not found
Constraints not found
Complexity Analysis
- Time Complexity: Google AdSense
- Space Complexity: Google Analytics
601. Human Traffic of Stadium LeetCode Solution in C++
WITH
StadiumNeighbors AS (
SELECT
id,
visit_date,
people,
LAG(people, 1) OVER(ORDER BY id) AS prev_people_1,
LAG(people, 2) OVER(ORDER BY id) AS prev_people_2,
LEAD(people, 1) OVER(ORDER BY id) AS next_people_1,
LEAD(people, 2) OVER(ORDER BY id) AS next_people_2
FROM Stadium
)
SELECT
id,
visit_date,
people
FROM StadiumNeighbors
WHERE
people >= 100 AND (
prev_people_1 >= 100 AND prev_people_2 >= 100
OR prev_people_1 >= 100 AND next_people_1 >= 100
OR next_people_1 >= 100 AND next_people_2 >= 100
)
ORDER BY visit_date;
/* code provided by PROGIEZ */
601. Human Traffic of Stadium LeetCode Solution in Java
WITH
StadiumWithGroupId AS (
SELECT
id,
visit_date,
people,
id - ROW_NUMBER() OVER(ORDER BY id) AS group_id
FROM Stadium
WHERE people >= 100
)
SELECT id, visit_date, people
FROM StadiumWithGroupId
WHERE group_id IN (
SELECT group_id
FROM StadiumWithGroupId
GROUP BY group_id
HAVING COUNT(*) >= 3
)
ORDER BY visit_date;
// code provided by PROGIEZ
601. Human Traffic of Stadium LeetCode Solution in Python
N/A
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.