leetcode-Add Digits
来源:互联网 发布:叮叮软件定位查询 编辑:程序博客网 时间:2024/06/06 03:14
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.
给一个非负整数,重复执行上面的操作,直到结果为一位数,返回该数。
public class Solution { public int addDigits(int num) { return (num-1)%9+1; }}
0 0
- [leetcode][math] Add Digits
- [leetcode] Add Digits
- 【leetcode】Add Digits【java】
- Leetcode: Add Digits
- LeetCode Add Digits
- [LeetCode] Add Digits
- leetcode 258: Add Digits
- LeetCode题解:Add Digits
- leetcode: Add Digits
- 258Add Digits - LeetCode
- leetCode #258 Add Digits
- [LeetCode 258] Add Digits
- LeetCode: Add Digits
- LeetCode:Add Digits
- leetcode--add digits
- leetcode Add Digits
- leetcode--Add Digits
- leetcode Add Digits
- Java 面试题
- 【数据结构】·【链表】·【JAVA版】
- 无题
- POJ2418 Hardwood Species(二叉搜索树+字典树+MAP)
- 分析JVM的性能利器-iotop和jstack
- leetcode-Add Digits
- HLG 1530 Pie(浮点二分)
- 开启我的博客之旅
- Java <!--随机数的产生 -->
- [LeetCode] Longest Increasing Subsequence
- Android 面试题目01
- tortoisegit 强制恢复回stage之前的代码
- Oracle数据库安装和PLSQL登陆表空间创建等基础
- 面试感悟——dmall