Daily Algorithm Practice: Cracking the Coding Interview, VI.12
That for loop is O(a * log(b)). Because it does the O(log(b)) binary search for every iteration, and it iterates O(a) times.
So O(b log b) + O(a log b). Neither of these terms can be dropped. Combined, we have O(b log b + a log b).
Comments
Post a Comment