K48
Moving Average from Data Stream
Problem Statement & Objective
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
Function Signature (Python)
moving_average_from_data_stream(size: int, nums: list[int]) -> list[float]Input & Output Contract
Output Rule:Her adımda hesaplanan ortalamaların float listesi (round(x, 2)).
System Constraints
1 <= boyut <= 1000
0 <= sayilar.length <= 10^4
-10^4 <= sayilar[i] <= 10^4Example Execution Walkthrough
boyut = 3, sayilar = [1, 10, 3, 5]
1. adım: [1] -> ort: 1.0
2. adım: [1, 10] -> ort: 5.5
3. adım: [1, 10, 3] -> ort: 4.67
4. adım: [10, 3, 5] (1 çıktı) -> ort: 6.0
Cevap: [1.0, 5.5, 4.67, 6.0]Example Test Scenarios (3)
Example 1: Boyut 3
Input:
[3,[1,10,3,5]]Expected Output:
[1,5.5,4.67,6]Example 2: Boyut 1
Input:
[1,[4,8,12]]Expected Output:
[4,8,12]Example 3: Single Element
Input:
[5,[10]]Expected Output:
[10]