247. Strobogrammatic Number II

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"].

一刷
题解:recursion, 每次n减少2,并从首尾append

public class Solution {
    public List findStrobogrammatic(int n) {
        return helper(n, n);
    }
    
    private List helper(int n, int m){
        List res = new ArrayList<>();
        if(n == 0){
            res.add("");
            return res;
        }
        if(n == 1){
            res.add("0");
            res.add("1");
            res.add("8");
            return res;
        }
        
        List list = helper(n-2, m);
        for(int i=0; i

你可能感兴趣的:(247. Strobogrammatic Number II)