• Shaarli
  • Tag cloud
  • Picture wall
  • Daily
  • RSS
  • Login
4418 shaares
Filters

The O(n^2) Bug That Looked Like Clean Code - Kitmul

QRCode

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)
https://kitmul.com/en/blog/hidden-quadratic-complexity-production-code
June 8, 2026 at 1:41:17 PM EDT *
sql javascript coding
FILLER
Shaarli · The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community · Documentation
Fold Fold all Expand Expand all Are you sure you want to delete this link? Are you sure you want to delete this tag? The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community