Leetcode 258 Solution
This article provides solution to leetcode question 258 (add-digits)
Access this page by simply typing in "lcs 258" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/add-digits
Solution
class Solution {
public:
int addDigits(int num) {
if (num == 0)
return 0;
else if (num % 9)
return num % 9;
else
return 9;
}
};