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.
Example:
Thoughts:
Recursion: T(n) = append each string with ("1", "1"); ("6","9"); ("9","6"); ("8","8"); if not at the out-most recursion; also add ("0","0") from returned element from T(n - 2); Base case: (n =0 => ['']; n = 1=>['0', '1', '8'])
Without Recursion: reverse the order with for loop
Code: Recursion
Code: Without Recursion
Last updated
Was this helpful?