title: Time complexity for finding if number is power of two
body: <p>What is the time complexity of this code to find if the number is power of 2 or not. </p>
  
  <p>Is it <strong>O(1)</strong>?</p>
  
  <pre><code>bool isPowerOfTwo(int x) {
      // x will check if x == 0 and !(x &amp; (x - 1)) will check if x is a power of 2 or not
      return (x &amp;&amp; !(x &amp; (x - 1)));
  }
  </code></pre>
  
  <h3><a href="https://leetcode.com/problems/power-of-two/" rel="nofollow noreferrer">LeetCode 231</a></h3>