Skip to content

Practice Consecutive Numbers

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#180
LeetCode Problem

Consecutive Numbers

Problem Statement

Tables: Logs(id INT, num VARCHAR). Logs.id is a unique auto-incrementing identifier starting at 1. Return each num appearing in at least three consecutive log positions, under the output name ConsecutiveNums. Emit each qualifying value once; output order is unrestricted.

Source: Consecutive Numbers on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
Logs table: +----+-----+ | id | num | +----+-----+ | 1  | 1   | | 2  | 1   | | 3  | 1   | | 4  | 2   | | 5  | 1   | | 6  | 2   | | 7  | 2   | +----+-----+
Output
+-----------------+ | ConsecutiveNums | +-----------------+ | 1               | +-----------------+

Related LeetCode Problems

Practice more problems similar to Consecutive Numbers.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.