Talentd
FleetCode

247. Strobogrammatic Number II

Medium53.5% acceptance2 companiesPremium elsewhere, free here

Given an integer n, return all the strobogrammatic numbers that are of length n. You may return the answer in any order.

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

Example 1:

Input: n = 2
Output: ["11","69","88","96"]

Example 2:

Input: n = 1
Output: ["0","1","8"]

Constraints:

  • 1 <= n <= 14

Asked at 2 companies

Hints open one at a time

Hint 1
Try to use recursion and notice that it should recurse with n - 2 instead of n - 1.
6:31
Still stuck?Read the written solution, or watch a walkthrough.
Open solution
Loading editor…
1class Solution:
2 def solve(self):
3 pass
4
Starter codePython 3Spaces: 4
Examples
Input
2
Input
1
Your code is saved on this device.Solution