501. Strobogrammatic Number

Given a string num which represents an integer, return true if num is a strobogrammatic number.

A strobogrammatic number is a number that appears the same when rotated 180 degrees (looked at upside down). This means each digit in the number must either map to itself or transform into another valid digit while maintaining the overall symmetry.

Example 1:

Input: num = "818"

Output: true

Example 2:

Input: num = "609"

Output: true

Now Your Turn!

Pick the correct output for the given input

Input: num = "123"

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= num.length <= 50
  • num consists of only digits.
  • num does not contain any leading zeros except for zero itself.

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
bool isStrobogrammatic(string num) {
// your code goes here
}
};
 
Test Case

Input:

Num