8 ms·
If it helps, this type of problem has come up precisely zero times ever. Use a built in function, loop through the array, and if in the future it's running slow
by decadentcactus 13y ago
If it helps, this type of problem has come up precisely zero times ever. Use a built in function, loop through the array, and if in the future it's running slow, _then_ optimise
- svachalek 13y agoYou don't need to optimize prematurely, but you should understand when/why/how to optimize something like this off the top of your head if you ever want to work at a company that deals with non-trivial amounts of data. If that's the hardest question I got asked at an interview, I'd never take the job.
- latch 13y agoHi. I wrote the post. I'm releasing a free ebook next Tuesday where hopefully I can change your mind. (I also wrote The Little Redis Book and The Little MongoDB Book, so hopefully you'll give me a chance!)
- cvursache 13y agoHow nice of you to share! Thank you Mr. latch (: