Imagine rotating a digital clock display 180 degrees - some numbers would still look like valid numbers, while others would become unreadable! This is the fascinating concept behind strobogrammatic numbers.
Given a string num representing an integer, determine if it's a strobogrammatic number - a number that looks identical when rotated 180 degrees (viewed upside down).
Key insight: Only certain digits remain valid when rotated:
0→01→16→98→89→6
All other digits (2, 3, 4, 5, 7) become invalid when rotated.
Example: "69" is strobogrammatic because when rotated 180°, it becomes "69" again!
Input & Output
Visualization
Time & Space Complexity
Single pass through the string, checking at most n/2 pairs of digits
Only using constant extra space for pointers and rotation mapping
Constraints
- 1 ≤ num.length ≤ 50
- num consists of only digits
- num does not contain any leading zeros except for the number 0 itself