题解 | #滑动窗口的最大值#
滑动窗口的最大值
http://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788
import java.util.*; public class Solution { public ArrayList<Integer> maxInWindows(int [] num, int size) { ArrayList<Integer> arr = new ArrayList<>(); if(size == 0) return arr; int [] k = new int[size]; for(int i = 0;i < num.length-size+1;i++){ for(int j = 0;j < size;j++){ k[j] = num [i+j]; } Arrays.sort(k); arr.add(k[size-1]); } return arr; } }