BEATS 100% | Easy java solution | Simple approach
IntuitionThe minElement method loops through an integer array.For each number, it calculates the sum of its digits using getDigitSum.It keeps track of the minim
# Intuition
The minElement method loops through an integer array.

For each number, it calculates the sum of its digits using getDigitSum.

It keeps track of the minimum digit sum found.

Returns the smallest digit sum among all numbers in the array.



# Complexity
- Time complexity:
minElement() loops n times, and each getDigitSum() call runs in O(d).
So,
Time Complexity = O(n * d) ~ O(n)

- Space complexity:

No extra space used except a few variables. O(1)

# Code
```java []
class Solution {
    public int minElement(int[] nums) {
        int min = Integer.MAX_VALUE;

        for (int num : nums) {
            int result = getDigitSum(num);
            min = Math.min(min, result); 
        }

        return min;
    }


    public int getDigitSum(int number) {
        int sum = 0;
        while (number != 0) {
            sum += number % 10;
            number /= 10;
        }
        return sum;
    }
}

```
['Java']