Is running a binary search on the interval from [0,k] really going to be faster than Math.floor(k ** 0.5)? This is a problem I would solve with a one liner in real code.
Python Book, 11.4. Integer Square Root
Hi @hughesj919,
I think Math.floor(k ** 5) is probably faster because the underly implementation might be in C or C++. However, the purpose of this question is most likely to be assuming you need to implement this library for this language, so such one-liner would not work in interview
0 Likes