
What Is a Pure Function? The Property Behind Memoization
A pure function returns the same output for the same input with no side effects. Here's why memoization and dynamic programming both require it.
Page 4 of 61 · Ideas for curious minds in tech.
Back to the archive
A pure function returns the same output for the same input with no side effects. Here's why memoization and dynamic programming both require it.

Referential transparency is the property that makes memoization safe. Learn why pure functions enable DP and what breaks when your function isn't pure.

Aliasing in Python is when two variables share one mutable object. Mutate through one, both change. This is the backtracking bug that produces empty results.
Deep copy vs shallow copy explained: why backtracking returns identical lists, how memory references work, and the one-character fix in every language.

String concatenation time complexity in a loop is O(n²). Here's why it happens, how StringBuilder fixes it, and the Python and JavaScript equivalents.

String interning stores one copy of each string in a shared pool. Learn the Python is vs == trap, Java string pool, and when to use sys.intern().

A unicode code point is the integer behind every character. Learn how it differs from code units, why emoji break JavaScript's length, and how to fix it.

ASCII vs Unicode explained for coding interviews: code points, UTF-8, Java surrogate pairs, and when to use a hash map instead of the array trick.

A nibble is 4 bits; a byte is 8. Learn what each holds, how they map to hex, and why integer overflow is a byte problem.

Integer overflow and underflow silently produce wrong answers. Learn the limits, the famous binary search bug, and how to avoid it in every language.
int32 vs int64 in coding interviews: when to upcast, the JDK binary search bug, and how overflow behaves in Java, C++, Rust, Go, Python, and more.

Integer vs floating point division silently breaks code in Java, C++, and Go. Here's what truncation vs floor means and the interview bugs to catch.

A buffer overflow writes past the end of a fixed-size buffer, corrupting adjacent memory. Learn how stack and heap overflows work, and why CVEs keep coming.

A segmentation fault kills your process with no stack trace. Learn what causes SIGSEGV, the four root bugs, and how to debug a segfault in C/C++.
A dangling pointer holds the address of freed or out-of-scope memory. What causes it, why the compiler won't warn you, and how GC, smart pointers, and Rust each solve it.

A memory leak is heap memory your program can't free. Learn what causes them in C, Python, JavaScript, and how they show up in interviews.

Spatial locality vs temporal locality: why two identical O(n²) loops run 15x apart, how cache lines work, and what it means for interviews.

Learn the cache hit vs cache miss distinction, the exact latency gap from L1 to DRAM, and why it matters in coding interviews.

A Bloom filter false positive occurs when hash collisions make a non-member look like a member. Here's the math, the formula, and when it's acceptable.

Rolling hash updates each window fingerprint in O(1) instead of rebuilding it. Learn the polynomial formula, Python code, and the LeetCode patterns it unlocks.

Population count (popcount) counts set bits in a binary integer. Learn Kernighan's trick, the DP recurrence for LeetCode 338, and every built-in.

A set bit is a 1 at a specific position. Learn the four bitmask operations that check, set, clear, and toggle bits, plus the n & (n-1) trick.

The bit shift operator moves bits left or right by k positions. Left vs right, arithmetic vs logical, and four patterns every coding interview tests.

Understand bitwise AND, OR, and XOR from first principles. Covers n & (n-1), XOR self-inverse, shift idioms, and common interview patterns.