Search
⌘K
Leetcode 788. Rotated Digits
Count how many integers in [1, n] consist only of rotatable digits (0,1,8,2,5,6,9) and contain at least one digit that changes when rotated (2,5,6,9). This is a per-digit counting/digit-DP problem: treat each position independently and count numbers ≤ n that avoid invalid digits (3,4,7) while excluding those made only of self-mapping digits (0,1,8).
Asked at:
Microsoft
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Late January, 2026
Microsoft
Mid-level
An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone.
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.