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
|
640 Discussions
|
Please Login in order to post a comment
from collections import deque n=int(input()) d=deque() for i in range(n): s=input().split(" ") if s[0]=="append": d.append(int(s[1])) elif s[0]=="appendleft": d.appendleft(int(s[1])) elif s[0]=="clear": d.clear() elif s[0]=="count": d.count(int(s[1])) elif s[0]=="extend": d.extend(int(s[1])) elif s[0]=="extendleft": d.extendleft(int(s[1])) elif s[0]=="pop": d.pop() elif s[0]=="popleft": d.popleft() elif s[0]=="remove": d.remove(int(s[1])) elif s[0]=="reverse": d.reverse() elif s[0]=="rotate": d.rotate(int(s[1])) print(*d)
from collections import deque
if name == 'main': N = int(input()) d = deque()
from collections import deque n = int(input()) d = deque() for _ in range(n): x =input().split() m = x[0] try: v= x[1] except Exception as e: pass
#
print(*d)
from collections import deque
d=deque([]) n=int(input()) for _ in range(n): method,*args=input().split() if args: getattr(d,method)(*map(int,args)) else: getattr(d,method)() print(*d)