Cheatsheet: Data Structures
    Array / List
    Map / Dict
    Set
    Tuple
    Struct / Data Class
    Stacks
    Other Data Structures
    Collection Conversions
Cheatsheet: Control Flow
Cheatsheet: Class

Polyglot CheatSheet - Stacks

Updated: 2022-04-08

Java

import java.util.Stack;

Stack<Integer> stack = new Stack<>();

stack.push(i);
stack.pop();

stack.isEmpty();

Python

List can be used as a stack:

stack = []

stack.append(1)
stack.pop()

# Check empty
not stack

Use collections.deque for quicker append() and pop():

from collections import deque

stack = deque()

stack.append(1)
stack.pop()