Skip to content

Commit 00eb45d

Browse files
authored
Create armstrong-number.py
1 parent 0729d2c commit 00eb45d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Python/armstrong-number.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Time: O(logn * logk)
2+
# Space: O(logn)
3+
4+
class Solution(object):
5+
def isArmstrong(self, N):
6+
"""
7+
:type N: int
8+
:rtype: bool
9+
"""
10+
n_str = str(N)
11+
return sum(int(i)**len(n_str) for i in n_str) == N

0 commit comments

Comments
 (0)