O90
Sliding Window Unique Element Counter
Problem Statement & Objective
Count distinct elements across a continuous high-throughput event sliding window.
Function Signature (Python)
sliding_window_unique_element_counter(nums: list[int], k: int) -> list[int]Input & Output Contract
Output Rule:Her penceredeki benzersiz eleman sayılarını içeren liste.
System Constraints
1 <= k <= sayilar.length <= 10^5
-10^4 <= sayilar[i] <= 10^4Example Execution Walkthrough
sayilar = [1, 2, 1, 3, 4, 2, 3], k = 4
[1, 2, 1, 3] -> 3 farklı (1, 2, 3)
[2, 1, 3, 4] -> 4 farklı
[1, 3, 4, 2] -> 4 farklı
[3, 4, 2, 3] -> 3 farklı
Cevap: [3, 4, 4, 3]Example Test Scenarios (3)
Example 1: Basic Window
Input:
[[1,2,1,3,4,2,3],4]Expected Output:
[3,4,4,3]Example 2: Tekrar Eden Elemanlar
Input:
[[1,1,1,1],2]Expected Output:
[1,1,1]Example 3: Boyut 1
Input:
[[1,2,3],1]Expected Output:
[1,1,1]