【leetcode】180. Consecutive Numbers

答案

select Num as ConsecutiveNums from (select T.Num, max(T.Count) as Count from (select Num, (case when @pre <> (@pre := Num) then @i := 1 else @i := @i + 1 end) as Count from Logs, (select @i:=0, @pre:=0) init) as T group by Num) as L where L.Count >= 3;

如果不懂,可以參考下下面兩個博客講解再來一步步寫這道題就ok了,加油,相信自己!
https://blog.csdn.net/changrj6/article/details/102508658
https://blog.csdn.net/changrj6/article/details/102483737

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章