class Solution {
private:
int addhelper(int num)
{
int sum=0;
while(num)
{
sum+=(num%10);
num/=10;
}
return sum;
}
public:
int addDigits(int num) {
do{
num=addhelper(num);
}while(num>=10);
return num;
}
};
258. Add Digits
最新推荐文章于 2024-06-29 18:30:29 发布