You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2><ahref="https://leetcode.com/problems/sqrtx">69. Sqrt(x)</a></h2><h3>Easy</h3><hr><p>Given a non-negative integer <code>x</code>, return <em>the square root of </em><code>x</code><em> rounded down to the nearest integer</em>. The returned integer should be <strong>non-negative</strong> as well.</p>
2
+
3
+
<p>You <strong>must not use</strong> any built-in exponent function or operator.</p>
4
+
5
+
<ul>
6
+
<li>For example, do not use <code>pow(x, 0.5)</code> in c++ or <code>x ** 0.5</code> in python.</li>
7
+
</ul>
8
+
9
+
<p> </p>
10
+
<p><strongclass="example">Example 1:</strong></p>
11
+
12
+
<pre>
13
+
<strong>Input:</strong> x = 4
14
+
<strong>Output:</strong> 2
15
+
<strong>Explanation:</strong> The square root of 4 is 2, so we return 2.
16
+
</pre>
17
+
18
+
<p><strongclass="example">Example 2:</strong></p>
19
+
20
+
<pre>
21
+
<strong>Input:</strong> x = 8
22
+
<strong>Output:</strong> 2
23
+
<strong>Explanation:</strong> The square root of 8 is 2.82842..., and since we round it down to the nearest integer, 2 is returned.
24
+
</pre>
25
+
26
+
<p> </p>
27
+
<p><strong>Constraints:</strong></p>
28
+
29
+
<ul>
30
+
<li><code>0 <= x <= 2<sup>31</sup> - 1</code></li>
0 commit comments