E
Euroken@euroken
I want to hear how people got from the obvious solution to the fast one on Two Sum.
The brute-force version checks every pair, which is O(n²). The faster version walks the list once and keeps a map of the numbers it has already seen, asking "have I seen the number that would complete this one?"
- Did you get there on your own, or did you see it somewhere first?
- Was it the idea of trading memory for time that was new, or the mechanics of the map?
- Can you explain it in one sentence to someone who has only seen loops?
Please do not paste a full solution without a spoiler warning. A description of the idea is more useful anyway.