Complexity cheat sheet: pick your algorithm by input constraints
cneuralnetwork · x · 2026-10-28
A widely shared cheat sheet for picking algorithmic complexity before writing code in online assessments:
- n ≤ 10 → exponential might work
- n ≤ 20 → 2^n brute force may pass
- n ≤ 500 → O(n²) usually fine
- n ≤ 10^5 → prefer O(n log n)
- n ≤ 10^6 → O(n) is safer
- n ≥ 10^9 → look for O(log n) / math solutions
The core idea: read the constraints first and reverse-engineer the acceptable time complexity from the input size.
More from coding & agent
- Don't let Claude pick your typography: set font styles yourself, then constrain it — hewarsaber · 2026-10-28
- Open-source Switch puts Claude Code in shared Slack rooms, ending the human-clipboard workflow — thetripathi58 · 2026-10-28
- JNISleuth-MCP open-sourced: LLMs reverse-engineer stripped Android ARM64 binaries — Dull-Plankton3027 · 2026-10-28
- Moonfold hands your coding task to another agent when one hits its usage limit — subaru_kun33 · 2026-10-28
- Grok 4.7 Sweeps Top 3 on VulcanBench Frontier v4, Beating Opus 5.5 and Sonnet 5.5 — XFreeze · 2026-10-28
- First-ever FastAPI Conf opens in Amsterdam with OpenAI and Pydantic talks — DynamicWebPaige · 2026-10-28