C++ | O(N) solution
IntuitionPretty much, just do what the problem tells you.
There is no room for optimizations.
Iterate the input
Calculate sum of digits for current number

If i
# Intuition
Pretty much, just do what the problem tells you.
There is no room for optimizations.
1. Iterate the input
2. Calculate sum of digits for current number
    - If input numbers had more digits, or the input had strings containing numbers, we could consider terminating early the sum of digits whenever it goes above the minimum sum of digits 
3. Update your minimum sum of digits if current sum is lower

# Complexity
- Time complexity: O(5 * N) = O(N)
    - Have to iterate all numbers in input
    - Each loop iteration takes about 5 operations since each number can have up to 5 digits as stated in the problem's constraint

- Space complexity: O(1)
    - No additional space required, we can solve this problem with just a few state variables

# Code
```cpp []
#include <vector>
#include <cstdint>
#include <algorithm>

class Solution {
public:
    uint8_t digit_sum(int32_t number) {
        uint8_t sum = 0;
        while (number != 0) {
            sum += number % 10;
            number /= 10;
        }
        return sum;
    }

    int minElement(vector<int>& nums) {
        const uint8_t maximum_digits = 5;
        const uint8_t maximum_sum = 9 * maximum_digits;
        uint8_t minimum_sum = maximum_sum;
        for (const int32_t& number : nums) {
            minimum_sum = std::min(
                minimum_sum,
                this->digit_sum(number)
            );
        }
        return minimum_sum;
    }
};
```
['C++']