function maxInWindows(num, size) { // write code here if(num == null || size <= 0){ return []; } // count为最后被选中的数组第一个元素下标 var count = num.length - size; var result = []; for(var i = 0;i<=count;i++){ var temp = num.slice(i,i+size); result.push(Math.max.apply(this,temp)); } return result; /* if( num == null ){ return []; } if(size == 1){ return num; } */ }