We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- Collections.deque()
- Discussions
Collections.deque()
Collections.deque()
Sort by
recency
|
645 Discussions
|
Please Login in order to post a comment
Here is my code
from collections import deque n = int(input()) d = deque() for i in range(n): command,*args = input().split() if args: getattr(d,command)(int(args[0])) else: getattr(d,command)() print(' '.join(map(str,d)))
from collections import deque
The fact that they’re memory efficient while maintaining great performance is another reason why they're a go-to in many scenarios. Definitely worth exploring the deque methods and recipes for anyone working with Python, 11winner register