Tap here to switch tabs
Problem
Submissions

Problem: Sqrt(x)

Sqrt(x) asks you to compute the square root of a non-negative integer, rounded down to the nearest non-negative integer, without using built-in exponentiation.

Statement

Given a non-negative integer x, compute and return the square root of x rounded down to the nearest integer. The result must also be non-negative.

Built-in exponent functions or operators (e.g., pow(x, 0.5) in C++ or x ** 0.5 in Python) are not permitted.

Constraints:

  • 0≤0 \leq x ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sqrt(x)

Sqrt(x) asks you to compute the square root of a non-negative integer, rounded down to the nearest non-negative integer, without using built-in exponentiation.

Statement

Given a non-negative integer x, compute and return the square root of x rounded down to the nearest integer. The result must also be non-negative.

Built-in exponent functions or operators (e.g., pow(x, 0.5) in C++ or x ** 0.5 in Python) are not permitted.

Constraints:

  • 0≤0 \leq x ≤231−1\leq 2^{31} - 1