Problem statement
Write function solution(values, windowSize). Inputs and outputs are JSON values. Do not modify input arrays or objects. External libraries, network access, and asynchronous functions are not supported. values:integer[] (-10^6…10^6), windowSize:integer 1–1024. Return the median of every consecutive full window in input order. For odd windows use the middle sorted value; for even windows average the two middle values. If fewer values than the window size, return []. Do not mutate input. Input limits: at most 50,000 items per input array and 1,000 characters per string. Numbers are finite; integers and accumulated integer results stay in the JavaScript safe-integer range. Other types and validity rules follow the statement above.
Example input and output
Example 1
Function arguments
[
[
1,
3,
2,
5,
4
],
3
]Return value
[ 2, 3, 4 ]
Example 2
Function arguments
[
[
1,
2,
3,
4
],
2
]Return value
[ 1.5, 2.5, 3.5 ]
Example 3
Function arguments
[
[
0,
0,
-1,
1
],
2
]Return value
[ 0, -0.5, 0 ]