LeetCode题解(1085):最小元素各数位之和(Python)
发布日期:2021-06-29 20:13:28 浏览次数:3 分类:技术文章

本文共 337 字,大约阅读时间需要 1 分钟。

题目:(简单)

标签:数组

解法 时间复杂度 空间复杂度 执行用时
Ans 1 (Python) O ( N ) O(N) O(N) O ( 1 ) O(1) O(1) 32ms (94.68%)
Ans 2 (Python)
Ans 3 (Python)

解法一:

class Solution:    def sumOfDigits(self, A: List[int]) -> int:        ans = float("inf")        for n in A:            ans = min(ans, n)        return 1 if sum(int(ch) for ch in str(ans)) % 2 == 0 else 0

转载地址:https://dataartist.blog.csdn.net/article/details/110730910 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:LeetCode题解(1099):小于K的两数之和(Python)
下一篇:LeetCode题解(1065):字符串的索引对(Python)

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月18日 04时04分51秒