My code below gave correct answer on my machine but OJ said:

Submission Result: Wrong Answer

Input: [1], 1

Output: []

Expected: [1]

The result array seemed not filled successfully. But I did fill it.

Can anybody tell what is wrong in my code?

```
int* maxSlidingWindow(int* nums, int numsSize, int k, int* returnSize) {
int resSize = numsSize - k + 1;
returnSize = &resSize;
int * res = (int*) malloc( sizeof(int) * (*returnSize) );
int * dq = malloc( numsSize * sizeof(int) ); // a deque to store the potential maximum elements
int start = 0;
int end = -1;
if( numsSize==0 ){
return res;
}
int i = 0; // consider the first k
while( i < k ){
while( end >= start && nums[ dq[end] ] <= nums[i] ){
end--; // delete the elements that cannot be the maximum
}
end++;
dq[end] = i; // push i
i++;
}
i = k;
int resEnd = -1;
while( i < numsSize ){
resEnd++;
res[resEnd] = nums[ dq[ start ] ]; // maximum element is always the first element of the deque
while( end >= start && nums[ dq[end] ] <= nums[i] ){
end--;
}
end++;
dq[end] = i;
while( end >= start && dq[start] <= i-k ){
start++; // delete the elements out of the window
}
i++;
}
resEnd++;
res[resEnd] = nums[ dq[start] ];
return res;
}
```

Thank you in advance!