Misc
Why Python?
- Less verbose than C++ & Java, concise syntax looks almost like pseudocode.
- Support wide range of data structures, e.g., priority queues via
heap
, Deque viadeque
, graph viadefaultdict
.
Patterns
- Nested loop: use
product
fromitertools
:
for i, j in product(range(N), range(N)):
...
- Memorization: Use
cache
infunctools
, almost always required for DP problems (unless you tabulate it).