A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).
Find all strobogrammatic numbers that are of length = n.
For example,
Given n = 2, return [“11”,”69”,”88”,”96”].
解法1: Recursion
承接I的思路,当数字长度大于1的时候,都需要配对存在。
要注意的是00配对只可能存在内层中,所以在递归的时候需要用一个变量记录原来n的长度。这样当不是最外层的时候就可以把0加上了。
|
|