# LeetCode 246. Strobogrammatic Number

## Description

https://leetcode.com/problems/strobogrammatic-number/

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.

Example 1:

```Input: num = "69"
Output: true
```

Example 2:

```Input: num = "88"
Output: true
```

Example 3:

```Input: num = "962"
Output: false
```

Example 4:

```Input: num = "1"
Output: true```

## Explanation

Create a reference mapping for strobo grammatic numbers. Then use the two-pointer technique to check if the numbers from left and right match the mapping.

## Python Solution

``````class Solution:
def isStrobogrammatic(self, num: str) -> bool:
mapping = {"9": "6", "6": "9", "8": "8", "1": "1", "0": "0"}

left = 0
right = len(num) - 1

while left <= right:
if num[left] in mapping and mapping[num[left]] == num[right]:
left += 1
right -= 1
else:
return False

return True
``````
• Time Complexity: ~N
• Space Complexity: ~1
{"ft_lang_label":"__label__en","ft_lang_prob":0.6445194,"math_prob":0.98829067,"size":959,"snap":"2021-21-2021-25","text_gpt3_token_len":271,"char_repetition_ratio":0.13193718,"word_repetition_ratio":0.0,"special_character_ratio":0.3076121,"punctuation_ratio":0.19473684,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99669355,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-13T21:10:35Z\",\"WARC-Record-ID\":\"<urn:uuid:4b38f05f-cab1-4849-be83-a40a38902093>\",\"Content-Length\":\"33282\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d196e924-d1bb-4ed0-80ee-c673d929f421>\",\"WARC-Concurrent-To\":\"<urn:uuid:0fc66714-8b48-4fba-994a-89e5c3304fc1>\",\"WARC-IP-Address\":\"72.44.43.28\",\"WARC-Target-URI\":\"https://goodtecher.com/leetcode-246-strobogrammatic-number/\",\"WARC-Payload-Digest\":\"sha1:STMZOSKKHXDZJDC6TLM2EWHYKIWVRDAG\",\"WARC-Block-Digest\":\"sha1:FMRDIXLHTWIKF5HLOIE7XZ5RAYJP7KBX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623487610841.7_warc_CC-MAIN-20210613192529-20210613222529-00076.warc.gz\"}"}