Math Fundamentals18 sections · 814 units
Open in Course

Lessons from Two Sum

summary

Two points:

1.1. Rearranging equations reveals the solution. a+b=ca + b = c becomes b=cab = c - a, telling you what to search for.

2.2. Hash maps convert O(n)O(n) searches into O(1)O(1) lookups. This pattern appears in many problems where you need to find pairs or complements.