Skip to content

Files

Latest commit

3bf118a · Jan 2, 2025

History

History
32 lines (26 loc) · 723 Bytes

Question_2526.md

File metadata and controls

32 lines (26 loc) · 723 Bytes

LeetCode Records - Question 2526 Find Consecutive Integers from a Data Stream

Attempt 1: Track the current target count

class DataStream {

    private int value;
    private int k;
    private int count;

    public DataStream(int value, int k) {
        this.value = value;
        this.k = k;
        this.count = 0;
    }
    
    public boolean consec(int num) {
        count = num == value ? count + 1 : 0;
        return count >= k;
    }
}

/**
 * Your DataStream object will be instantiated and called as such:
 * DataStream obj = new DataStream(value, k);
 * boolean param_1 = obj.consec(num);
 */
  • Runtime: 25 ms (Beats: 100.00%)
  • Memory: 101.54 MB (Beats: 38.21%)