Integer Square Root Calculation

Given a positive integer 'N', compute its square root and return it. If 'N' is not a perfect square, then return the floor value of sqrt(N).

Example:

Input:
N = 25
N = 20
N = 2
Output:
5
4
1

Explanation:

For 'N' = 25, the output is 5 as 5*5 = 25. For 'N' = 20, the output is 4 because the floor value of the square root of 20 is 4. Similarly, for 'N' = 2, the floor value of the square root is 1.

Constraints:

  • 1 <= T <= 5
  • 0 <= N <= 1016
  • Time Limit: 1 sec.
Be the first one to answer
Add answer anonymously...
NetApp Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter