It would IMHO be more correct to say that the time complexity of the solution is O(n*log n), since that 32 is the result of calculating logarithm of the biggest allowed n. If n were to be allowed to grow beyond 1e9 the number 32 would also need to be revisited. Just like in the last problem the loop condition can be instead expressed as while (1