LeetCode题解(1134):阿姆斯特朗数(Python)
发布日期:2021-06-29 20:13:31 浏览次数:2 分类:技术文章

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

题目:(简单)

标签:数学

解法 时间复杂度 空间复杂度 执行用时
Ans 1 (Python) O ( l o g N ) O(logN) O(logN) O ( l o g N ) O(logN) O(logN) 36ms (80.28%)
Ans 2 (Python)
Ans 3 (Python)

解法一:

class Solution:    def isArmstrong(self, N: int) -> bool:        lst = [int(ch) for ch in str(N)]        ans = 0        size = len(lst)        for i in range(size):            ans += lst[i] ** size        return ans == N

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

上一篇:LeetCode题解(1150):检查一个数是否在数组中占绝大多数(Python)
下一篇:LeetCode题解(1119):删去字符串中的元音(Python)

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月10日 05时38分38秒