4 ms·
Who wouldn’t just sort the array and check it? His solution is very brittle: it fails in so many ways if the data had unexpected properties. Real world require
by paulsutter 4y ago
Who wouldn’t just sort the array and check it? His solution is very brittle: it fails in so many ways if the data had unexpected properties.
Real world requirements usually contain inaccurate assumptions. He spent days to find a terrible answer, when the obvious solution is much better
- whiplash451 4y agoMaybe those who care about computational complexity for instance?
- paulsutter 4y agoEven if you had terabytes of data sorting is still the easiest answer. Especially if you had terabytes of data in fact. Brittle solutions suck Start with what works and then optimize Sophomoric is exactly the word here, and it’s no surprise that the story is about Microsoft
- whiplash451 4y agoAm I missing something or sorting is n.log(n) when the sum trick is linear time? In the lack of additional constraint, sorting seems massively overkill. Not sure why you are saying that sorting is simpler than the sum trick.
- paulsutter 4y agoThe author spent days thinking about it, whereas sorting is the immediate obvious answer. Developer time is massively more valuable than computer time by a factor of 1000 And the clever approach only works on data that is perfect, and that’s extremely rare in the real world This is a hypersophomoric question
- qcoh 4y agoHow is it brittle? It solves the problem at hand, which is unambiguous (I think).