my solution


  • 5
    1

    In fact, this is a "no primary key" table ,so it is possible to have same line like “A - math” “A - math”;
    and in this case, you query should count 1 instead of 2.
    here is my query:

    select class
    from courses
    group by class
    having count(distinct student)>=5;


  • 1
    R

    My solution is as same as yours, but the first time I submitted it returning TLE. After reading this post, I tried again, and got Accepted, miraculous.


  • 0
    F

    @rucliangyuan said in my solution:

    My solution is as same as yours, but the first time I submitted it returning TLE. After reading this post, I tried again, and got Accepted, miraculous.

    I think you forgot to put DISTINCT in your statement


Log in to reply
 

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