kennymkchan / interview-questions-in-javascript

A mostly reasonable collection of technical software development interview questions solved in Javascript
MIT License
3.61k stars 441 forks source link

perf improvement #30

Closed rishabhbhatia closed 6 years ago

rishabhbhatia commented 6 years ago

Hi Kenny, was practising the questions. Submitting a perf improvement to 1.4, thank you. @kennymkchan

kennymkchan commented 6 years ago

Personally, I do not think that there is a performance improvement doing this, just because we are now doing an addition N checks during our condition.

screen shot 2018-07-31 at 1 06 01 am

Speed difference is irrelevant on small arrays but as arrays scale, the difference will increase.