該系列共三道題,Company Tag只有一個Google
,那就必需要作了。ide
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as a string. For example, the numbers "69", "88", and "818" are all strobogrammatic.
直接按照題目要求來,人家要什麼就給什麼,這題要求判斷,那就判斷。從兩頭開始,我這邊是1,那翻過來仍是1,0和8都是,有區別的就是6和9,由於上下顛倒頗有可能致使性別的不一樣,因此左邊是6的話,對稱位置必須是9。因此這題先創建一個對應的map,而後掃一遍字符串就能夠了。code
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"].
一看關鍵詞find/return all
#$%^,一般都是DFS,深搜一遍,挖地三尺,雁過拔毛。three
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. For example, Given low = "50", high = "100", return 3. Because 69, 88, and 96 are three strobogrammatic numbers. Note: Because the range might be a large number, the low and high numbers are represented as string.