1
# Runtime: 65 ms (Top 7.05%) | Memory: 13.8 MB (Top 68.36%)3
def countDigitOne(self, n: int) -> int:6
for i in range(len(num) - 1, -1, -1):7
pv = 10**i # placevalue8
# mulitplicity of current digit (how many times it will be repeated)10
rem = n % pv # remainder of current place value13
) # count for number of times 1 occurs in this place when the current digit is considered to be less than 114
# if the current digit is greater than 1 then additional number of 1's are added to the count (equivalent to the place value)17
# if the current digit is equal to 1 then additional number of 1's are added to the count (equivalent to the number modded by the current place value)