Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- /**
- * @param k: An integer
- * @param n: An integer
- * @return: An integer denote the count of digit k in 1..n
- */
- int digitCounts(int k, int n) {
- // write your code here
- int result=1;
- if (k==0){k=10;}
- while(n!=1){
- n = n/k;
- result += n;
- }
- return result;
- }
- };
Add Comment
Please, Sign In to add comment