3 ms·
I think his point was that if you're seeking out all the pairs when you curl them together, you're still spending unnecessary time and effort matching socks, ju
by kenbellows 11y ago
I think his point was that if you're seeking out all the pairs when you curl them together, you're still spending unnecessary time and effort matching socks, just ahead of time instead of in the moment when you need socks
- brianwawok 11y agoExactly he does an O(N^2) Pair followed by a later O(N) search. Why not do a O(1) Pair folloed by an O(1) Search.
- dtparr 11y agoOf course, there's an enlightening stackoverflow question on this: http://stackoverflow.com/q/14415881/220347 http://stackoverflow.com/q/14415881/220347 Finally, my graduate-level algorithms class comes in handy in real life.
- djfm 11y agoIntuitively I'd say a human pairing socks is far better than O(n2) because finding something that matches a given sock is close to O(1) on small sets.