Square Root of Integer

Implement int sqrt(int x).

Compute and return the square root of x.

If x is not a perfect square, return floor(sqrt(x))

Example :

Input : 11
Output : 3

DO NOT USE SQRT FUNCTION FROM STANDARD LIBRARY

Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
9615 successful submissions.
Asked In:
  • Facebook
  • Amazon
  • Microsoft
Click here to jump start your coding interview preparation