786. Find square root of a number
Given a positive integer n. Find and return its square root. If n is not a perfect square, then return the floor value of sqrt(n).
Example 1:
Input: n = 36
Output: 6
Explanation: 6 is the square root of 36.
Example 2:
Input: n = 28
Output: 5
Explanation: The square root of 28 is approximately 5.292. So, the floor value will be 5.
Now Your Turn!
Pick the correct output for the given inputInput: n=50
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- Â 0 <= n <= 231 - 1