Problem Link - Finding Square Roots Practice Problem in 500 to 1000 difficulty problems
Problem Statement:
Finding Square root of a number using in-built square-root function.
Approach:
- Use a built-in function (e.g.,
sqrt()
in C++ or Python) to compute the square root ofN
. - Round the result down to the nearest integer using functions like
floor()
or by casting to an integer (e.g.,int(sqrt(N))
).
Complexity:
- Time Complexity:
O(1)
Thesqrt()
function runs inO(1)
for eachN
- Space Complexity:
O(1)
Not using any extra space.