Skip to content

Finding square root of a number using Binary Search [O(log N) approach] #2504

@sahil-13399

Description

@sahil-13399

Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x).

For example,
if x = 5, The answer should be 2 which is the floor value of √5.

The approach that will be used for solving the above problem is not going to be a straight forward Math.sqrt(). Instead we will be using Binary Search to find the square root of a number in the most optimised way.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions