258. Add Digits
Easy
Given an integer num
, repeatedly add all its digits until the result has only one digit, and return it.
Example 1:
Example 2:
Constraints:
0 <= num <= 231 - 1
Follow up: Could you do it without any loop/recursion in O(1)
runtime?
解題
官方理想的正解:
Last updated