Sqrt(x)
Given a non-negative integer x, return the square root of x rounded down to the nearest integer.
Sqrt(x)

Given a non-negative integer x, return the square root of x rounded down to the nearest integer.

Example 1:
Input: 8
Output: 2
Input
arr =8

Binary search

Target

8

mid = 0

0² = 0

Comparison

0 < 8

LR11²=122²=433²=944²=16
L: 1
mid: 0
R: 4
Variables
VariableValue
left1
right4
DepthFunction Call
Stack empty
0/3