Add LeetCode 231

This commit is contained in:
Evandro Nakayama Mota 2019-10-28 17:06:18 -03:00
parent 2e692eddeb
commit 8f0602c9f1
2 changed files with 6 additions and 0 deletions

View File

@ -52,6 +52,7 @@ LeetCode
|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/) | [C](./src/215.c)|Medium|
|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate/) | [C](./src/217.c)|Easy|
|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/) | [C](./src/226.c)|Easy|
|231|[Power of Two](https://leetcode.com/problems/power-of-two/) | [C](./src/231.c)|Easy|
|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list/) | [C](./src/234.c)|Easy|
|268|[Missing Number](https://leetcode.com/problems/missing-number/) | [C](./src/268.c)|Easy|
|278|[First Bad Version](https://leetcode.com/problems/first-bad-version/) | [C](./src/278.c)|Easy|

5
leetcode/src/231.c Normal file
View File

@ -0,0 +1,5 @@
bool isPowerOfTwo(int n){
if (! n) return false;
while (n % 2 == 0) n /= 2;
return n == 1;
}