Ctrl K

Same When Flipped

Easy
A sign shows a number written as a string of digits digits. The sign is turned through 180°. Return True if it reads exactly the same after the turn, and False otherwise. When turned, 0, 1 and 8 stay themselves, 6 becomes 9 and 9 becomes 6. The other digits (2, 3, 4, 5, 7) no longer look like digits. Turning the sign also reverses the order of the digits.
Example 1
digits='619' → True

Turned over, 6 becomes 9, 1 stays 1 and 9 becomes 6, and the order reverses: it reads "619" again.

Example 2
digits='88' → True

An 8 turns into itself.

Example 3
digits='26' → False

An upside-down 2 is not a digit at all.

Constraints
  • 1 ≤ digits.length ≤ 50
  • digits consists of digits only
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Subsequence of One Word Only MediumHidden Anagram MediumPieces Without Shared Letters MediumWord Growth Chain MediumErasable Marked Letters Medium
loading Python…
Input
digits='619'
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 183 tests on the server, hidden ones included.