3300. 替换为数位和以后的最小元素

题目链接:
https://leetcode.cn/problems/minimum-element-after-replacement-with-digit-sum/
题解代码:

int minElement(int* nums, int numsSize) {
    int temp=10000;
    while (numsSize--) {
        int a=0;
        while (nums[numsSize]) {
            a += nums[numsSize] % 10;
            nums[numsSize] /= 10;
        }temp = temp > a ? a : temp;
    }return temp;
}
posted @ 2024-11-12 21:56  fufuaifufu  阅读(6)  评论(0编辑  收藏  举报