FSQRT - Editorial

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 of N.
  • 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) The sqrt() function runs in O(1) for each N
  • Space Complexity: O(1) Not using any extra space.