💢☠💫Easiest👾Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅C#✅💥🔥💫Explained☠💥🔥 Beats 100
Intuition\n\n Describe your first thoughts on how to solve this problem. \njavascript []\n//JavaScript Solution\n/**\n * @param {number[]} nums\n * @return {num
# Intuition\n![0ehh83fsnh811.jpg](https://assets.leetcode.com/users/images/5b3640ff-cc15-4c82-adca-c192e39a7a15_1727546185.431474.jpeg)\n<!-- Describe your first thoughts on how to solve this problem. -->\n```javascript []\n//JavaScript Solution\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minElement = function(nums) {\n    let ans = Infinity;\n\n        for (let num of nums) {\n            const digitSum = num.toString().split(\'\').reduce((sum, digit) => sum + Number(digit), 0);\n            ans = Math.min(ans, digitSum);\n        }\n\n        return ans;\n};\n```\n```C++ []\n//?C++ Solution\n#include <bits/stdc++.h>\nusing namespace std;\n\n#define FOR(a, b, c) for (int a = b; a < c; a++)\n#define FOR1(a, b, c) for (int a = b; a <= c; ++a)\n#define Rep(i, n) FOR(i, 0, n)\n#define Rep1(i, n) FOR1(i, 1, n)\n#define RepA(ele, nums) for (auto& ele : nums)\n\nclass Solution {\npublic:\n    int minElement(vector<int>& nums) {\n        int ans = INT_MAX;\n        RepA (num, nums){\n            int sum = 0;\n            string str = to_string(num);\n            RepA (c, str)\n                sum += c - \'0\';\n            ans = fmin(ans, sum);\n        }\n        return ans;\n    }\n};\n```\n```Python3 []\n#Python3 Solution\nclass Solution:\n    def minElement(self, nums: List[int]) -> int:\n        return min(sum(int(d) for d in str(num)) for num in nums)\n```\n```Java []\n//Java Solution\nclass Solution {\n    public int minElement(int[] nums) {\n        int n = nums.length;\n        int ans = Integer.MAX_VALUE;\n        for (int x : nums) {\n            int sum = 0;\n            while (x != 0) {\n                sum += (x % 10);\n                x /= 10;\n            }\n            ans = Math.min(ans, sum);\n        }\n        return ans;\n    }\n}\n```\n```C []\n//C Solution\n\nint minElement(int* nums, int numsSize) {\n    int ans = INT_MAX;\n    for (int i = 0; i < numsSize; ++i) {\n        int sum = 0;\n        while(nums[i]) {\n            sum += nums[i] % 10;\n            nums[i] /= 10;\n        }\n        ans = fmin(ans, sum);\n    }\n    return ans;\n}\n```\n```python []\n#Python SOlution\nclass Solution(object):\n    def minElement(self, nums):\n        """\n        :type nums: List[int]\n        :rtype: int\n        """\n        ans = float(\'inf\')\n        for num in nums:\n            ans = min(ans, sum(ord(x) - ord(\'0\') for x in str(num)))\n        return ans\n```\n```C# []\n//C# Solution\npublic class Solution {\n    public int MinElement(int[] nums) {\n        var ans = Int32.MaxValue;\n        foreach (var x in nums) {\n            var sum = 0;\n            var num = x;\n            while (num != 0) {\n                sum += num % 10;\n                num /= 10;\n            }\n            ans = Math.Min(ans, sum);\n        }\n        return ans;\n    }\n}\n```\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n![th.jpeg](https://assets.leetcode.com/users/images/dd5f4074-350b-4dbf-b5aa-8b63eab0e81a_1727546531.1698544.jpeg)\n
['Math', 'String', 'C', 'Python', 'C++', 'Java', 'Python3', 'JavaScript', 'C#']