dsa · easy

Check if Kth Bit is Set

GreyOrangeBit ManipulationFoundation

Return whether the k-th bit of n is set. k is **1-indexed from the right** (LSB is bit 1).

Arguments

**Example:** n=5 (101), k=1true; k=2false.

Constraints

0 <= n <= 10^9, 1 <= k <= 31

Examples

Example 1

Input:
5
1

Expected:
true

Example 2

Input:
5
2

Expected:
false

Open in the Dojo editor