难度:中等
1. Description
2. Solution
- python
class Solution:
"""
@param n: An integer
@return: An array storing 1 to the largest number with n digits.
"""
def numbersByRecursion(self, n):
# write your code here
if n==0:
return []
if n==1:
return [1,2,3,4,5,6,7,8,9]
tmp = self.numbersByRecursion(n-1)
ans = []
ans.extend(tmp)
for i in range(10**(n-1),10**n):
ans.append(i)
return ans