Big-O basics, hot vs cold paths (beginner wins)
Use Big-O intuition and focus on hot paths. Replace nested scans with Set/Map, avoid repeated work, and keep code small and clear.
Big picture
Goal: Quick wins without complex theory.
- Big-O intuition: avoid double loops
- Hot vs cold paths: optimize what runs most
- Set/Map for fast lookups
- Do work once, reuse results

Nested scan = costly
Nesting scans multiplies work. Each includes walks the array again.
// Bad pattern: nested scan for membership (can be ~O(n^2))
const haystack = ["a","b","c","d","e"];
const needles = ["b","e","x"];
const foundSlow = [];
for (const n of needles) {
// includes scans the array each time
if (haystack.includes(n)) {
foundSlow.push(n);
}
}
console.log("slow found:", foundSlow);

All lessons in this course
- Big-O basics, hot vs cold paths (beginner wins)
- Avoiding leaks — closures, timers, references
- Profiling intro (Node/DevTools) — tiny timing habits