File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ Personal Practice Set - Doing One a Day (sometimes) in a Variety of Languages!!
35
35
| 54 | Medium | [ Spiral Matrix] ( leetcode/54-Medium-Spiral-Matrix/problem.md ) | [ Python] ( leetcode/54-Medium-Spiral-Matrix/answer.py ) |
36
36
| 58 | Easy | [ Length of Last Word] ( leetcode/58-Easy-Length-Of-Last-Word/problem.md ) | [ Python] ( leetcode/58-Easy-Length-Of-Last-Word/answer.py ) |
37
37
| 66 | Easy | [ Plus One] ( leetcode/66-Easy-Plus-One/problem.md ) | [ Python] ( leetcode/66-Easy-Plus-One/answer.py ) |
38
+ | 69 | Easy | [ Sqrt()] ( leetcode/69-Easy-Sqrt/problem.md ) | [ Python] ( leetcode/69-Easy-Sqrt/answer.py ) |
38
39
| 70 | Easy | [ Climbing Stairs] ( leetcode/70-Easy-Climbing-Stairs/problem.md ) | [ C] ( leetcode/70-Easy-Climbing-Stairs/answer.c ) |
39
40
| 83 | Easy | [ Remove Duplicates from Sorted List] ( leetcode/83-Easy-Remove-Duplicates-From-Sorted-List/problem.md ) | [ Python] ( leetcode/83-Easy-Remove-Duplicates-From-Sorted-List/answer.py ) |
40
41
| 100| Easy | [ Same Tree] ( leetcode/100-Easy-Same-Tree/problem.md ) | [ Python] ( leetcode/100-Easy-Same-Tree/answer.py ) |
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ #-------------------------------------------------------------------------------
4
+ class Solution (object ):
5
+ def mySqrt (self , x ):
6
+ """
7
+ :type x: int
8
+ :rtype: int
9
+ """
10
+ r = x
11
+ while r * r > x :
12
+ r = (r + x / r ) / 2
13
+ return r
14
+ #-------------------------------------------------------------------------------
15
+ # Testing
Original file line number Diff line number Diff line change
1
+ # Problem 69: Sqrt()
2
+
3
+
4
+ #### Difficulty: Easy
5
+
6
+ #### Problem
7
+
8
+ Implement int sqrt(int x).
9
+
10
+ Compute and return the square root of x.
11
+
12
+ x is guaranteed to be a non-negative integer.
13
+
14
+ #### Example
15
+
16
+ <pre >
17
+
18
+ Input: 4
19
+ Output: 2
20
+
21
+ Input: 8
22
+ Output: 2
23
+ Explanation: The square root of 8 is 2.82842..., and since we want to return an integer, the decimal part will be truncated.
24
+
25
+
26
+ </pre >
You can’t perform that action at this time.
0 commit comments