4 ms·
I said θ ;) In other words, your algorithm is asymptotically too fast and you failed the interview! :D
by dirtdobber 2y ago
I said θ ;)
In other words, your algorithm is asymptotically too fast and you failed the interview! :D
- cben 2y agoYou could add "without using multiplication or division" as a less arbitrary constraint. Early microprocessors (and some really cheap microcontrollers still) didn't have the circuitry. That said a fixed-factor mutiplication can probably be done faster AND [more] precisely as a sum of some shifts. Or many other ways with a lookup table.