Lintcode 3:Digit Counts
来源:互联网 发布:python 图形化界面 编辑:程序博客网 时间:2024/05/29 11:59
Description:
Count the number of k's between 0 and n. k can be 0 - 9.
Note:
直接暴力做。当k为零的时候特殊处理下。
Count the number of k's between 0 and n. k can be 0 - 9.
Note:
直接暴力做。当k为零的时候特殊处理下。
Code:
class Solution {public:/** @param : An integer* @param : An integer* @return: An integer denote the count of digit k in 1..n*/int digitCounts(int k, int n) {// write your code hereint i, tmp;int result = 0;for (i = 0; i <= n; i++) {tmp = i;while (tmp) {if (tmp % 10 == k)result++;tmp /= 10;}}if(!k) ++result;return result;}};
阅读全文
0 0
- Lintcode 3:Digit Counts
- lintcode:Digit Counts
- **[Lintcode]Digit Counts
- #3 Digit Counts
- digit-counts
- Digit Counts 解题报告
- Problem 63 Powerful digit counts
- Project Euler 题解 #63 Powerful digit counts
- Project Euler:Problem 63 Powerful digit counts
- 3.Digit Counts-统计数字(中等题)
- 算法学习笔记--7.digit-counts
- Digit Divide Numbers-LintCode
- LINTCODE——Digit Divide Numbers
- 1.2.3 Reference Counts(引用计数)
- STM32 Tutorial: #3 Show digit
- Lintcode(3)-字符串查找
- lintcode:3 Sum Closest
- lintcode:3 Sum
- Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip dfs 按位考虑
- Django UnicodeEncodeError
- 【Hibernate】mysql版本影响hibernate操作数据库
- Kafka的基本shell命令
- Attribute 和 Parameter 的区别
- Lintcode 3:Digit Counts
- Tarjan无向图最小权值割边
- uml类图&类的关系
- hdu5546 Ancient Go(bfs)
- python 爬虫简单使用
- [LeetCode] 181. Employees Earning More Than Their Managers
- (crm笔记1-3)Service层搭建
- Git:代码冲突常见解决方法
- 二分图匹配以及交叉染色