LeetCode solutions

2620. Find Consecutive Integers from a Data Stream

My accepted Python solution to LeetCode problem 2620, Find Consecutive Integers from a Data Stream, running in 70ms.

  • Difficulty: Medium
  • Python
  • Runtime 70ms
  • Memory 49.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 70ms, memory 49.3MB, accepted 2025-12-31.

python
class DataStream:

    def __init__(self, value: int, k: int):
        self.value = value
        self.k = k
        self.count = 0  # Count of consecutive matches

    def consec(self, num: int) -> bool:
        if num == self.value:
            self.count += 1
        else:
            self.count = 0
        return self.count >= self.k


# Your DataStream object will be instantiated and called as such:
# obj = DataStream(value, k)
# param_1 = obj.consec(num)

Source