[
math
simulation
]
BinarySearch 0308 Narcissistic Number
Problem statement
https://binarysearch.com/problems/Narcissistic-Number/
Solution
Just do what is asked.
Complexity
Complexity of this oneliner is O(k^2)
, where k
is the number of digits in n
.
Code
class Solution:
def solve(self, n):
return n == sum(int(x)**len(str(n)) for x in str(n))