不找优化了
import java.util.*; public class Solution { public ArrayList<Integer> maxInWindows(int [] num, int size) { ArrayList<Integer> list = new ArrayList<Integer>(); if(size> num.length || size == 0) return list; Queue<Integer> window = new LinkedList<Integer>(); int max = -1; for(int i = 0; i<num.length; i++){ if(window.size()<size) window.offer(num[i]); if(window.size() == size) { list.add(findmax(window)); window.poll(); } } return list; } public int findmax(Queue<Integer> window){ int max = -1; for(int i: window){ max = Math.max(max,i); } return max; } }