Stacks
A stack is a collection of elements that supports two main operations: push (adds an element to the top of the stack) and pop (removes the top element from the stack).
python
# Create a stack using a list
stack = []
# Push an element onto the stack
stack.append(1)
# Pop an element from the stack
top_element = stack.pop()
No comments:
Post a Comment