For this Question: You are given an array A of size N. You have to print the maximum in every <b>K-sized subarray</b> from the left to the right in the array A.
More formally, you have to print N - K + 1 integers X<sub>1</sub>, X<sub>2</sub>, ..., X<sub>N-K+1</sub> such that X<sub>i</sub> (1 <= i <= N - K + 1) is the maximum element in the subarray A<sub>i</sub>, A<sub>i+1</sub>, ..., A<sub>i+K-1</sub>.1. The first line contains an integer N, denoting the size of the array.
2. The second line has N space-separated integers of the array A.
3. The third line contains integer K, denoting the size of the sliding window

<b>Constraints :</b>
1 &le; N &le; 10<sup>5</sup>
-10<sup>4</sup> &le; A[i] &le; 10<sup>4</sup>
1 &le; K &le; NPrint the max of K numbers for each position of sliding windowSample Input:-
8
1 3 -1 -3 5 3 6 7
3

Sample Output:-
3 3 5 5 6 7

Explanation:-
Window position       Max
- - - -
[1 3 -1] -3 5 3 6 7         3
1 [3 -1 -3] 5 3 6 7         3
1 3 [-1 -3 5] 3 6 7         5
1 3 -1 [-3 5 3] 6 7         5
1 3 -1 -3 [5 3 6] 7         6
1 3 -1 -3 5 [3 6 7]         7

Sample Input:-
1
1
1

Sample Output:-
1 , I have written this Solution Code: N = int(input())
A = [int(x) for x in input().split()]
K = int(input())

def print_max(a, n, k):
    max_upto = [0 for i in range(n)]
    s = []
    s.append(0)
    for i in range(1, n):
        while (len(s) > 0 and a[s[-1]] < a[i]):
            max_upto[s[-1]] = i - 1
            del s[-1]
        s.append(i)
 
    while (len(s) > 0):
        max_upto[s[-1]] = n - 1
        del s[-1]
 
    j = 0
    for i in range(n - k + 1):
        while (j < i or max_upto[j] < i + k - 1):
            j += 1
        print(a[j], end=" ")
    print()

print_max(A, N, K), In this Programming Language: Python, Now tell me if this Code is compilable or not?