public int[] maxSlidingWindow(int[] nums, int k) {
        if (nums == null || nums.length == 0)
            return new int[0];
        int[] ans = new int[nums.length - k + 1];
        Deque<Integer> queue = new LinkedList<>();
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < k; ++i) {
            queue.offerLast(nums[i]);
            max = Math.max(max, nums[i]);
        }
        ans[0] = max;
        int index = 1;
        for (int i = k; i < nums.length; ++i) {
            queue.pollFirst();
            queue.offerLast(nums[i]);
            ans[index++] = findMax(queue);
        }
        return ans;
    }