using System;
using System.Collections.Generic;


class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param num int整型一维数组
     * @param size int整型
     * @return int整型一维数组
     */
    public List<int> maxInWindows (List<int> num, int size) {
        LinkedList<int> maxNum = new LinkedList<int>();
        List<int> res = new List<int>();
        if(size == 0 || size > num.Count) return res;
        maxNum.AddLast(num[0]);
        for (int i = 1; i < size; i++) {
            while (maxNum.Count != 0 && maxNum.Last.Value < num[i]) maxNum.RemoveLast();
            maxNum.AddLast(num[i]);
        }
        res.Add(maxNum.First.Value);
        for (int i = size; i < num.Count; i++) {
            if (num[i - size] == maxNum.First.Value) maxNum.RemoveFirst();
            while (maxNum.Count != 0 && maxNum.Last.Value < num[i]) maxNum.RemoveLast();
            maxNum.AddLast(num[i]);
            res.Add(maxNum.First.Value);
        }
        return res;
    }
}