What's wrong with my logic?

I am printing the max in every window of k using a queue

Link to my code : https://ide.codingblocks.com/s/227451

hello @Avi-Kasliwal-315786729062203
image
u are pushing element value in place of their index.

due to which this line will not make any sense becuase here u are comparing index with value.
image .

to rectify it push index in place of value.

and use a[q.back()] in place of q.back for element comparision.

rest everthing is correct in ur code.