use some joins


  • 0
    L

    find candidate ids and print out

    SELECT DISTINCT c.*
    FROM stadium c
    INNER JOIN
    (
    SELECT a.id id, MIN(b.people) min_people, COUNT(1) units_around
    FROM stadium a
    INNER JOIN stadium b
    ON a.id - b.id BETWEEN -1 AND 1
    GROUP BY a.id
    ) d
    ON c.id - d.id BETWEEN -1 AND 1
    WHERE d.min_people >= 100 and d.units_around = 3


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.