Check if the i-th Bit is Set or Not
Implement isBitSet
Given a number
n and a bit position i (0-indexed from the least significant bit), determine whether the bit at position i is set (1) or clear (0).
Every bit position in n can be isolated by lining it up with position 0 through a shift, or by building a mask that targets it directly — either way, the answer falls out of a single AND once the right bit lines up.
Example 1:
Input: n = 10, i = 1
Output: true
Example 2:
Input: n = 10, i = 0
Output: false
Example 3:
Input: n = 1, i = 0
Output: true
+ 10 hidden test cases run on Submit.
Constraints:
- ●
0 ≤ n ≤ 2³¹ − 1 - ●
0 ≤ i ≤ 31
n =
10
i =
1