Files
tira/viikko11/stack.py
T
2026-03-26 17:03:42 +02:00

25 lines
439 B
Python

import collections
import time
def stack(n):
start = time.time()
stack = collections.deque()
for x in range(n):
stack.append(x)
add_end = time.time()
for x in range(n):
stack.popleft()
end = time.time()
return f"Total: {end - start:.2f} seconds, to add: {add_end - start:.2f}, to delete: {end - add_end:.2f}"
def main():
print(stack(10**5))
if __name__ == "__main__":
main()