← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Meta/Leetcode 231. Power of Two
CodingOptional
Write a function that determines whether a given integer is a power of two. An integer is considered a power of two if it can be expressed as 2 raised to some non-negative integer exponent (2^x where x >= 0).
Your function should return true if the number is a power of two, and false otherwise.
Example 1:
Input: n = 16 Output: true Explanation: 16 equals 2^4
Example 2:
Input: n = 3 Output: false Explanation: 3 cannot be expressed as 2^x for any integer x
Example 3:
Input: n = 1 Output: true Explanation: 1 equals 2^0
Example 4:
Input: n = -8 Output: false Explanation: Negative numbers cannot be powers of two