K43

Square Root (Sqrt x)

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: NUMERIC

Problem Statement & Objective

Given a non-negative integer x, return the square root of x rounded down to the nearest integer. Do not use built-in exponent functions.

Function Signature (Python)

my_sqrt(x: int) -> int

Input & Output Contract

Output Rule:Karekökün taban tam sayısı.

System Constraints

0 <= x <= 2^31 - 1

Example Execution Walkthrough

x = 4 -> 2
x = 8 -> 2 (2.828.. aşağı yuvarlanır -> 2)

Example Test Scenarios (3)

Example 1: Tam Kare
Input:[4]
Expected Output:2
Example 2: Yuvarlama
Input:[8]
Expected Output:2
Example 3: Sıfır
Input:[0]
Expected Output:0
Loading Python Editor...
Input Parameters
[
  4
]
Expected Output
2