30:00
You are given an integer array nums.
nums
Replace every element of nums with the sum of its digits.
Return the minimum element of nums after all replacements.
1≤nums.length≤1001 \leq nums.length \leq 1001≤nums.length≤100
1≤nums[i]≤1041 \leq nums[i] \leq 10^41≤nums[i]≤104
Run code to see results.
best starts at infinity. Each of the 4 numbers will be squashed into the sum of its digits, and best keeps the smallest sum.
x -> sum of digits of x
10
·
12
13
14
best
∞
Replace every element of nums with the sum of its digits and return the smallest value that results.