💯Very Easy Brute Force Solution || 🎯 Array and Maths
Intuition\n Describe your first thoughts on how to solve this problem. \nWe will compute the sum of the digits of each elements of the array and replace it with
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe will compute the sum of the digits of each elements of the array and replace it with the corresponding element, then get the minimum of this computed array.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. **Helper Function sum(int n):**\n    - The function takes an integer \'n\' and computes the sum of its digits.\n    - It does this by extracting each digit (\'n % 10\') and adding it to the \'total\' while dividing \'n by 10\' in each iteration to move to the next digit.\n    - This process continues until \'n becomes 0\'.\n\n2. **Main Function minElement(int[] nums):**\n    - Step 1: The input is an array nums of integers. For each element in the array, the sum of its digits is calculated using the \'sum()\' function, and the array element is replaced with this \'sum\'.\n    - Step 2: Once the sums of digits replace the elements in \'nums\', the code searches for the \'minimum\' value in the modified array.\n    - Step 3: The function returns the \'smallest sum of digits\' from the array.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n*logk)$$, where k is the maximum number in the nums.\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$.\n# Code\n```java []\nclass Solution {\n    public int sum(int n){\n        int total = 0;\n        while(n > 0){\n            total += n%10;\n            n = n/10;\n        }\n        return total;\n    }\n    public int minElement(int[] nums) {\n        int n = nums.length;\n        for(int i=0; i<n; i++){\n            int a = sum(nums[i]);\n            nums[i] = a;\n        }\n        \n        int min = Integer.MAX_VALUE;\n        for(int i=0; i<n; i++){\n            min = Math.min(min, nums[i]);\n        }\n        return min;\n    }\n}\n```
['Array', 'Math', 'Java']