leetcode_258_Add Digits
来源:互联网 发布:js根据name获取标签 编辑:程序博客网 时间:2024/05/18 00:08
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?
First, I assumed that I should transfer a string into char, and then did something. So I read this blog.
http://blog.csdn.net/kankan_summer/article/details/7243493
But, we should do it without any loop/recursion in O(1) runtime. I did not know how to do, so I found these solutions.
http://blog.csdn.net/xudli/article/details/47786855
http://my.oschina.net/Tsybius2014/blog/497645
http://blog.csdn.net/booirror/article/details/47710779
http://my.oschina.net/Tsybius2014/blog/497645
- leetcode_258_Add Digits
- Leetcode_258_Add Digits
- leetcode_258_Add Digit(easy)(C++)
- 11687 - Digits
- Swapping Digits
- POJ3373Changing Digits
- hdu4333Revolving Digits
- uva11198Dancing Digits
- Swap Digits
- Add Digits
- Add Digits
- Add Digits
- Add Digits
- Add Digits
- LeetCode_Add Digits
- Delete Digits
- Add Digits
- Add Digits
- 自己练习一之对象的访问和对象的存储和指针
- 2015/10/04 阴雨天纪事
- android中listview 异步加载防止图片移位
- IMS技术
- iOS按钮的使用和动画的实现
- leetcode_258_Add Digits
- MMD_4b_SVD
- HDOJ 5498 Tree
- 线性筛
- main函数
- iOS 常用控件
- Gym 100685 G Gadget Hackwrench LCA+DFS标记
- 欢迎使用CSDN-markdown编辑器
- 自己的练习二之构造函数与初始化列表