a short solution


  • 0
    C

    This answer didn't use the id column though..
    '''select distinct num ConsecutiveNums from (
    select
    case
    when @prev<>@prev:=num then @n:=1
    else @n:=@n+1
    end n, num
    from Logs, (select @n:=1, @prev:=-1) init) mytable
    where n >=3'''


Log in to reply
 

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