Leetcode 258 258
来源:互联网 发布:4g网络优化工程师培训 编辑:程序博客网 时间:2024/06/12 03:55
Given a non-negative integer num
, repeatedly add all its digits until the result has only one digit.
For example:
Given num = 38
, the process is like: 3 + 8 = 11
, 1 + 1 = 2
. Since 2
has only one digit, return it.
Follow up:
Could you do it without any loop/recursion in O(1) runtime?
数学的方法
class Solution {public: int addDigits(int num) { return 1 + (num-1) % 9; }};
0 0
- Leetcode 258
- leetcode 258
- Leetcode 258 258
- leetcode 258: Add Digits
- 【LeetCode】258_Add Digits
- 258Add Digits - LeetCode
- leetCode #258 Add Digits
- [LeetCode 258] Add Digits
- LeetCode(258)Add Digits
- leetcode-258-Add Digits
- [leetcode 258]Add Digits
- [Leetcode]#258 Add Digits
- LeetCode 258----Add Digits
- LeetCode 258 : Add Digits
- 【LeetCode】258 Add Digits
- Leetcode - 258 - Add Digits
- leetcode 258 :Add Digits
- leetcode 258--Add Digits
- 遍历磁盘信息
- android自定义组件
- 资源配置
- 关于数据库连接中断错误
- Webstorm Eclipse快捷键
- Leetcode 258 258
- IPSec VPN基本原理
- String,StringBuffer做参数
- SerDes interface参考设计_测试实验(7)
- matlab和c#联合仿真之一(VS2010,Matlab2012a)
- ConcurrentHashMap之实现细节
- python使用MySQLdb操作数据库
- Mac 常见扩展名
- Leetcode #237 Delete Node in a Linked List