How to Solve NameError: name 'deque' is not defined -- collections
Solution: Import the 'deque' module
To Solve the error, add the following line to the top of your code.
from collections import deque
For more information:
Python collections deque