Confusing numbers
A confusing number is one that, when each digit is rotated 180 degrees, becomes a different valid number. Only digits 0,1,6,8,9 are rotatable (0->0, 1->1, 6->9, 8->8, 9->6); any number containing 2,3,4,5,7 is not rotatable at all. Rotating reverses the digit order. Given `n`, count how many integers in [1, n] are confusing numbers. 1 <= n <= 1000000000.
Implement
confusing_number_ii(n: int) → intExamples
in
[20]out6What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 35 min
solution.py
InputExpectedGot
[20]6not run yetsample