K43
Square Root (Sqrt x)
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) -> intInput & Output Contract
Output Rule:Karekökün taban tam sayısı.
System Constraints
0 <= x <= 2^31 - 1Example 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:
2Example 2: Yuvarlama
Input:
[8]Expected Output:
2Example 3: Sıfır
Input:
[0]Expected Output:
0