public class Solution {
    public int NumberOf1Between1AndN_Solution(int n) {
        
        if (0 == n) {
            return 0;
        }
        
        int res = 0;
        for (int i = 1; i <= n; i++) {
            res += process(i);
        }
        return res;
    }
    
    public int process(int num) {
        String str = num + "";
        int total = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '1') {
                total++;
            }
        }
        return total;
    }
}