We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db31d10 commit 4d5037bCopy full SHA for 4d5037b
1 file changed
find-the-numbers.py
@@ -0,0 +1,25 @@
1
+class Solution:
2
+ """
3
+ @param n: the integer
4
+ @return: the numbers that larger and smaller than `n`
5
6
+ def getNumbers(self, n):
7
+ # Write your code here
8
+ if n < 0:
9
+ return []
10
+ if n == 0:
11
+ return [1]
12
+ n0, n1 = 0, 1
13
+ r = [-1, -1]
14
+ while True:
15
+ if n0 < n:
16
+ r[0] = n0
17
+ if n1 > n:
18
+ r[1] = n1
19
+ break
20
+ _n = n0 + n1
21
+ n0 = n1
22
+ n1 = _n
23
+ return r
24
+
25
+# medium: https://www.lintcode.com/problem/1610/
0 commit comments