Sword finger Offer 43. 1~n Integer 1 Number of times
1 | class Solution: |
That day, I made a set of Xiaomi measurement questions.,The first one is calculation1~nmiddle1Number of times。
Deduction的题号yesSword fingeroffer 43
nyes12in the case of,1 10 11 12middle就出现了5Second-rate1。
因为那套题middle选择题都yes简单难度,So naturally I want to use violent algorithm to crack。
但yes拿到Deductionmiddle找相同的题的时候却发现标签yesdifficulty[Be ashamedR]。Surmo after timeout[picture2]。
Then I actually thought about it directly with mathematical methods,But why too lazy, don’t want to find the rules,[picture三]yes标答,I feel that I have to sink in the future and slowly go to do it.。
#Deduction #algorithm#Deductionalgorithm #Python
Error answer:
1 | def countDigitOne(self, n: int) -> int: |