@@ -0,0 +1,745 @@
+import org.junit.Test;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * https://leetcode.com/problems/number-of-digit-one/%0A */%0Apublic class Solution %7B%0A%0A    public int countDigitOne(int n) %7B%0A        int count = 0, lowc = 1, lown = 0;%0A        while(n %3E 0) %7B%0A            int c = n %25 10;%0A            n /= 10;%0A            if (c == 1) %7B%0A                count += n * lowc + lown + 1;%0A            %7D%0A            else if (c == 0) %7B%0A                count += n * lowc;%0A            %7D%0A            else %7B%0A                count += (n + 1) * lowc;%0A            %7D%0A            lown = c * lowc + lown;%0A            lowc = lowc * 10;%0A        %7D%0A        return count;%0A    %7D%0A%0A%0A    @Test%0A    public void test() %7B%0A        assertEquals(23, countDigitOne(101));%0A    %7D%0A%7D%0A

number of one digits