The O(n^2) Bug That Looked Like Clean Code - Kitmul
Five production-breaking patterns where quadratic complexity hides behind readable, idiomatic JavaScript. Why .find() inside .map() passes code review and fails at scale; and the one-line fixes that drop O(n^2) to O(n).
- Pattern 1: The innocent .includes() inside .filter()
- Pattern 2: Deduplication by comparison
- Pattern 3: The cascading .map().filter().map()
- Pattern 4: The recursive tree flattener
- Pattern 5: The SQL query in a loop (the N+1 problem)
June 8, 2026 at 1:41:17 PM EDT
*
FILLER