247 Strobogrammatic Number II
Last updated
Was this helpful?
Last updated
Was this helpful?
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"]
.
Attempt 1: TLE
The Idea: Build from the base case of an empty array. Notice how the edges do not include zeros, and if this were an odd array, then the center wouldn't contain either 6 or 9.
Complexity: O(5^n) time, but more specifically 4*5*5... for even case and 4*5*5*3 for odd case. The time taken for the deepcopy makes TLE.