题目链接:https://leetcode.cn/problems/minimum-element-after-replacement-with-digit-sum/
题解代码:
class Solution {
public:
int minElement(vector<int>& nums) {
vector<int> n;
for(int i = 0;i < nums.size();i ++)
{
int x = nums[i];
int cnt = 0;
while(x)
{
cnt += x % 10;
x /= 10;
}
n.push_back(cnt);
}
sort(n.begin(),n.end());
return n[0];
}
};
标签:10,cnt,nums,int,vector,替换,3300,数位
From: https://www.cnblogs.com/chhh31/p/18541008