Numbers That Contain D — Solution & Editorial
Complement counting: numbers with NO digit D are easy to count by a digit walk (each free position has 9 choices); subtract from N.
Complexity: O(log N)
Complement counting: numbers with NO digit D are easy to count by a digit walk (each free position has 9 choices); subtract from N.
Complexity: O(log N)