the problem is referring to this leetcode question
And below is the code for the solution using dequeue in Python:
from collections import deque def p