diff options
Diffstat (limited to '')
-rw-r--r-- | 1342/main.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/1342/main.cpp b/1342/main.cpp new file mode 100644 index 0000000..b8609d9 --- /dev/null +++ b/1342/main.cpp @@ -0,0 +1,21 @@ + +#include "header.hpp" + +class Solution { +public: + static int numberOfSteps(int num) { + auto dummy = num; + int counter = 0; + while (dummy != 0) { + if (dummy % 2 == 0) { + dummy = dummy >> 1; + } else { + dummy--; + } + counter++; + } + return counter; + } +}; + +int main(int argc, char **argv) { std::cout << Solution::numberOfSteps(123); } |