GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — LeetCode-Solutions/MySQL/consecutive-numbers.sql at master · basketscript/LeetCode-Solutions Expand file tree/ Copy pathconsecutive-numbers.sqlMore file actions 17 lines (14 loc) · 447 Bytes / Copy pathconsecutive-numbers.sqlFile metadata and controls17 lines (14 loc) · 447 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # Time: O(n) # Space: O(n) SELECT DISTINCT(Num) AS ConsecutiveNums FROM ( SELECT Num, @counter := IF(@prev = Num, @counter + 1, 1) AS how_many_cnt_in_a_row, @prev := Num FROM Logs y, (SELECT @counter:=1, @prev:=NULL) vars ) sq WHERE how_many_cnt_in_a_row >= 3 SELECT DISTINCT l1.Num as ConsecutiveNums FROM Logs l1, Logs l2, Logs l3 WHERE l1.Id + 1 = l2.Id AND l2.Id + 1 = l3.Id AND l1.Num = l2.Num AND l2.Num = l3.Num |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |