Easy
Quiz
#258 Add Digits
APPROACH
Given a non-negative integer num, keep replacing it with the sum of its digits until only a single digit remains. Return that single digit.
Example 1:
Input: num = 38
Output: 2
Explanation: The process is
38 --> 3 + 8 --> 11
11 --> 1 + 1 --> 2
Since 2 has only one digit, return it.
Example 2:
Input: num = 0
Output: 0
1 of 4
1:00
What is the optimal approach for this problem?