Minimum element
IntuitionWe are given an array of integers, and we want to find the number with the smallest digit sum.
Instead of comparing the original numbers, we convert ea


# Intuition
We are given an array of integers, and we want to find the number with the **smallest digit sum**.  
Instead of comparing the original numbers, we convert each number to the sum of its digits and find the minimum among those.

---

# Approach
1. Loop through the array.
2. For each number, convert it to a string to access each digit.
3. Convert each digit character back to an integer and compute the sum of its digits.
4. Replace the original number in the array with this digit sum.
5. Use Java’s built-in `Arrays.stream().min().getAsInt()` to find the minimum digit sum.

---

# Complexity
- **Time complexity:**  
  $$O(n \cdot d)$$  
  where \( n \) is the number of elements in the array, and \( d \) is the average number of digits per element.

- **Space complexity:**  
  $$O(1)$$  
  We are modifying the original array in-place and using only a few extra variables.

---

# Code
```java
import java.util.Arrays;

class Solution {
    public int minElement(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            String numStr = String.valueOf(nums[i]);
            int temp = 0;
            for (int j = 0; j < numStr.length(); j++) {
                temp += Character.getNumericValue(numStr.charAt(j));
            }
            nums[i] = temp;
        }
        return Arrays.stream(nums).min().getAsInt();
    }
}

['Java']