247. Strobogrammatic Number II
Input: n = 2
Output: ["11","69","88","96"]class Solution(object):
def findStrobogrammatic(self, n):
"""
:type n: int
:rtype: List[str]
"""
def helper(cur_len, total_len):
# base case
if cur_len == 0: return ['']
if cur_len == 1: return ['0', '1', '8']
ans = []
sub = helper(cur_len - 2, total_len)
for s in sub:
if cur_len != total_len:
ans.append("0" + s + "0")
ans.append("1" + s + "1")
ans.append("6" + s + "9")
ans.append("8" + s + "8")
ans.append("9" + s + "6")
return ans
return helper(n, n)Last updated
Was this helpful?