Set k-th bit
Java
Easy
5 views
Problem Description
Task: set k-th bit (0-indexed) in x and return result.
Output Format
Return value
Constraints
k between 0..30.
Official Solution
static int setBit(int x,int k){return x | (1<<k);}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!