```
int[] result = new int[nums.Length-k+1];
if (nums == null||k==0) return nums;
if (k == 1) return nums;
else
{
for (int i = 0; i < nums.Length - k + 1; ++i)
{
result[i] = nums[i];
for (int j = i; j < k+i;++j )
{
result[i] = Math.Max(result[i],nums[j]);
}
}
}
return result;
```