Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Leetcode/Armstrong_Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution {
public:
bool isArmstrong(int N) {
const auto& n_str = to_string(N);
return accumulate(n_str.cbegin(), n_str.cend(), 0,
[&](const auto& x, const auto& y) {
return x + pow(y - '0', n_str.length());
}) == N;
}
}