Integer Square Root — Solution & Editorial
Binary search the answer in [0, 109]: mid² ≤ N moves the lower bound up. Floating-point sqrt is off by one near 1018.
Complexity: O(log N)
Binary search the answer in [0, 109]: mid² ≤ N moves the lower bound up. Floating-point sqrt is off by one near 1018.
Complexity: O(log N)