Find Race Numbers That Become Different Valid Numbers Upside Down

Quick Overview

Find confusing upside-down race numbers by reversing and mapping digits, rejecting leading zeros and unchanged values, and checking valid bib membership.

Find Race Numbers That Become Different Valid Numbers Upside Down

Company: Verily

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Find race-bib numbers in the range 1 through N that become a different valid number after a 180-degree rotation. A rotated representation with a leading zero is invalid: 10 becomes `01`, so it is not confusing. For example, 666 rotates to 999. ### Constraints & Assumptions Use the explicit conventional digit mapping `0->0`, `1->1`, `6->9`, `8->8`, and `9->6`; other digits are invalid. Require the rotated number to remain in 1 through N. The source gives the rotation examples but does not fully specify font-dependent digits or range membership, so confirm these assumptions. ### Clarifying Questions to Ask - Which digits are valid in the bib font after rotation? - Must the rotated value be another assigned/in-range bib number? - Are unchanged numbers such as 69 excluded? This formulation excludes them. ```hint Rotation changes order too A 180-degree rotation reverses the digit sequence as well as mapping individual digits. ``` ### What a Strong Answer Covers - Reversing and mapping digits, rejecting invalid digits and leading zeros. - Excluding unchanged values and applying the chosen range rule. - Complexity of checking the full bib range. ### Follow-up Questions - How could you generate only candidates containing rotatable digits? - How would an explicit set of assigned bibs replace the contiguous range?

Overview: Find confusing upside-down race numbers by reversing and mapping digits, rejecting leading zeros and unchanged values, and checking valid bib membership.

Read the full Verily Software Engineer interview experience this question came from

Verily logo
Verily
Nov 4, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
0
0

Find race-bib numbers in the range 1 through N that become a different valid number after a 180-degree rotation. A rotated representation with a leading zero is invalid: 10 becomes 01, so it is not confusing. For example, 666 rotates to 999.

Constraints & Assumptions

Use the explicit conventional digit mapping 0->0, 1->1, 6->9, 8->8, and 9->6; other digits are invalid. Require the rotated number to remain in 1 through N. The source gives the rotation examples but does not fully specify font-dependent digits or range membership, so confirm these assumptions.

Clarifying Questions to Ask Guidance

  • Which digits are valid in the bib font after rotation?
  • Must the rotated value be another assigned/in-range bib number?
  • Are unchanged numbers such as 69 excluded? This formulation excludes them.

What a Strong Answer Covers Guidance

  • Reversing and mapping digits, rejecting invalid digits and leading zeros.
  • Excluding unchanged values and applying the chosen range rule.
  • Complexity of checking the full bib range.

Follow-up Questions Guidance

  • How could you generate only candidates containing rotatable digits?
  • How would an explicit set of assigned bibs replace the contiguous range?