Skip to content

Commit 60606dc

Browse files
committed
Added README.md file for Power of Two
1 parent 8744205 commit 60606dc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

231-power-of-two/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/power-of-two">Power of Two</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>Given an integer <code>n</code>, return <em><code>true</code> if it is a power of two. Otherwise, return <code>false</code></em>.</p>
2+
3+
<p>An integer <code>n</code> is a power of two, if there exists an integer <code>x</code> such that <code>n == 2<sup>x</sup></code>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> n = 1
10+
<strong>Output:</strong> true
11+
<strong>Explanation: </strong>2<sup>0</sup> = 1
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> n = 16
18+
<strong>Output:</strong> true
19+
<strong>Explanation: </strong>2<sup>4</sup> = 16
20+
</pre>
21+
22+
<p><strong class="example">Example 3:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> n = 3
26+
<strong>Output:</strong> false
27+
</pre>
28+
29+
<p>&nbsp;</p>
30+
<p><strong>Constraints:</strong></p>
31+
32+
<ul>
33+
<li><code>-2<sup>31</sup> &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
34+
</ul>
35+
36+
<p>&nbsp;</p>
37+
<strong>Follow up:</strong> Could you solve it without loops/recursion?

0 commit comments

Comments
 (0)