bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 180. Consecutive Numbers

180. Consecutive Numbers

Leetcode Solutions

Finding Consecutive Numbers Using Self-Join

  1. Perform a self-join on the Logs table three times, creating aliases l1, l2, and l3.
  2. Join l1 with l2 where l2.id is l1.id + 1.
  3. Join l2 with l3 where l3.id is l2.id + 1.
  4. Check that l1.num, l2.num, and l3.num are the same.
  5. Use the DISTINCT keyword to select unique num values that meet the above conditions.
  6. Return the result with the column alias ConsecutiveNums.
erDiagram
    Logs {
        int id PK
        varchar num
    }

Finding Consecutive Numbers Using Window Functions

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...