```
public class Solution {
public int[] MaxSlidingWindow(int[] nums, int k)
{
if(nums == null || nums.Count() == 0 || k<=0)
return nums;
var result = new List<int>();
var ll = new LinkedList<int>();
for(int i = 0; i<nums.Count(); i++)
{
if(ll.Any() && ll.First.Value <= i-k)
{
ll.RemoveFirst();
}
while(ll.Any() && nums[ll.Last.Value]<=nums[i])
{
ll.RemoveLast();
}
ll.AddLast(i);
if(i-k+1 >=0)
result.Add(nums[ll.First.Value]);
}
return result.ToArray();
}
}
```