Leet Code Problem - 69 - Sqrt(x) - Difficulty Level : Easy
Hello All, Welcome back to another algorithm challenge. Today we are going to look at LeetCode problem number 69 where you need to find square root of input number. Please find below link for detailed statement of problem. https://leetcode.com/problems/sqrtx/ Now if we read that problem statement , it's given that we can not use pow(x, 0.5) or x ** 0.5. Now instead of focusing on calculating power root , we will focus on calculating square of number and we try to compare with input weather it matches or not. If my input greater is less than power we calculated , then again we loop find bigger square value. Now one approach to solve this problem is you start with number 1 and keep calculating square until you reach either equal or greater number than input provided. But this approach will increase my time complexity. Better approach would to use Binary Search algorithm approach which can give me result in O(logn) time. Algorithm : Let's looks at step by step appro...