Swift💯
Good Interview Answer (accepted answer)\n\nclass Solution {\n    func minElement(_ nums: [Int]) -> Int {\n        var smallest = Int.max\n        for var num in
**Good Interview Answer (accepted answer)**\n```\nclass Solution {\n    func minElement(_ nums: [Int]) -> Int {\n        var smallest = Int.max\n        for var num in nums {\n            var digitSum = 0\n            while num > 0 {\n                digitSum += num % 10\n                num /= 10\n            }\n            smallest = min(smallest, digitSum)      \n        }\n        return smallest\n    }\n}\n```\n\n**BONUS: Rewritten as one-liner (accepted answer)**\n```\nclass Solution {\n    func minElement(_ nums: [Int]) -> Int {\n        nums.map{num in [1,10,100,1000,10000].map{(num/$0) % 10}.reduce(0,+)}.min()!\n    }\n}\n```
['Swift']