public class Solution { public int NumberOf1Between1AndN_Solution(int n) { if(n==0){ return 0; } int count=0; for(int i = 1;i<=n;i++){ String str = Integer.toString(i); char[] chars = str.toCharArray(); for(int j=0;j<chars.length;j++){ if(chars[j]=='1'){ count++; } } } return count; } }