diff --git a/c++/Leetcode_question/Power_Of_Two.cpp b/c++/Leetcode_question/Power_Of_Two.cpp new file mode 100644 index 00000000..fb4baf5e --- /dev/null +++ b/c++/Leetcode_question/Power_Of_Two.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + bool isPowerOfTwo(int n) { + + for (int i = 0; i<=30; i++){ + int ans = pow(2,i); + if(ans == n) + { + return true; + } + + } + return false; + } +};