posted 10 years ago
You shouldn't worry about doing it "in the minimum time possible", but in the clearest way for someone else (or even yourself in 3 months) to understand the code. If you need to compare a million pairs of arrays, and by using clever tricks you save 1 microsecond per check, your total savings is one second.
but if it takes you an additional eight hours to understand your code next month, you've lost out.
The first rule of writing code is "do it right". ONLY if once you've done that and you have a DOCUMENTED reason to make it faster should you look at improving things.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors