A sensor at a dam logs one water-level reading every hour. The list nums holds these readings in time order. A reading can be negative.
An engineer studies the readings k hours at a time. First she looks at hours 1 to k. Then she moves one hour ahead and looks at the next k hours. She repeats this until the last hour is covered.
For each of these looks, find the highest reading among the k hours she can see. Return all of these highest readings in order.
Examples
Example 1:
Input: nums = [4,2,12,3,8,1,7], k = 3
Output: [12,12,12,8,8]
Explanation: The five looks are [4,2,12], [2,12,3], [12,3,8], [3,8,1] and [8,1,7]. Their highest readings are 12, 12, 12, 8 and 8.
Example 2:
Input: nums = [5,1,3], k = 3
Output: [5]
Explanation: There is only one look, and it covers the whole list. The highest reading is 5.
Example 3:
Input: nums = [1,2,3,4], k = 1
Output: [1,2,3,4]
Explanation: She sees one reading at a time, so each reading is its own highest one.