A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high.
Example:
**Input: low = "50", high = "100"
**Output:** 3
Explanation: 69, 88, and 96 are three strobogrammatic numbers.
Note: Because the range might be a large number, the lowand high numbers are represented as string.
defstrobogrammaticInRange(self, low: str, high: str) -> int: stro_dict = {'0': '0', '1': '1', '8': '8', '6': '9', '9': '6'} res = 0 res += self.dfs('', low, high, stro_dict) res += self.dfs('0', low, high, stro_dict) res += self.dfs('1', low, high, stro_dict) res += self.dfs('8', low, high, stro_dict) return res
defdfs(self, s, low, high, stro_dict): if len(s) > len(high) or (len(s) == len(high) and s > high): return0 res = 0 if len(s) > len(low) or (len(s) == len(low) and s >= low): res = 1 if len(s) > 1and s[0] == '0': # i.e. 08 res = 0 for key, val in stro_dict.items(): res += self.dfs(key + s + val, low, high, stro_dict) return res