Python, Data Science, Data Engineering, Programming, Coding.
deque when we need to add or remove items from both ends of a collection. Deque Operations & Time Complexity Basic Operations from collections import deque # Creating a deque deque1 = deque([1,2,3,4,5]) # Adding an item to the right of a deque deque1.append(6) # Adding an item to the left of a