Giving TLE for 1 test case? Rest all test cases passed

i have gine through your code;
your approach is not optimised and that is why it is givivng TLE .
this is the question of queue or deque.
try to solve with that.
that techanique solves the question in O(N) time.
if you have any doubt you can ask here:
Happy Learning!!

my bad ,just create a dequeu without size k .like: deque<int> q;