1314. Copy Set Bits of a Number in Another

EasyBit ManipulationBit ManipulationORMerge

Given two non-negative integers src and dst, return dst with every bit that is set in src also set (all set bits of src are copied into dst).

Input: A JSON object {"src": <non-negative integer>, "dst": <non-negative integer>}.

Output: Return dst OR src.

Examples

Example 1
Input: {"src":5,"dst":8}
Output: 13
Explanation: 1000 | 0101 = 1101 = 13.
Example 2
Input: {"src":0,"dst":12}
Output: 12
Explanation: No bits to copy, dst stays 12.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →