Skip to content

Practice Sqrt(x)

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#69
LeetCode Problem

Sqrt(x)

Problem Statement

Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator.

Source: Sqrt(x) on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
x = 4
Output
2

# Example 2

Input
x = 8
Output
2

Constraints

0 <= x <= 2^31 - 1

Related LeetCode Problems

Practice more problems similar to Sqrt(x).

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.