import java.util.*;
public class Solution {
    public ArrayList<Integer> maxInWindows(int [] num, int size) {

        ArrayList<Integer> result = new ArrayList<Integer>();

        //注意:这里不能判断num.length==0 这种情况应该返回[]
        if (num == null || size == 0) {
            return result;
        }

        //数组的大小是n,窗口的大小是size,那么窗口的数量就是 n - size + 1
        for (int windowIndex = 0; windowIndex < (num.length - size + 1); windowIndex++) {

            int max = num[windowIndex];

            for (int windowStep = 0; windowStep < size; windowStep++) {
                //获取以windowIndex为起点的窗口内的最大值
                max = Math.max(max, num[windowIndex + windowStep]);
            }

            result.add(max);
        }

        return result;
    }
}