Question: Security System You are working on a security system that uses a binary key to unlock a vault. The key consists of a series of
Security System
You are working on a security system that uses a binary key to unlock a vault. The key consists of a series of bits, each representing a specific function of the security system.
You are given an integer value N which represents the curfent binary key configuration gor and an integer value B which represents the bit position that needs to be toggled to
activate the security feature.
a Your task is to find and return an integer value representing the updated binary key configuration after toggling the Nth bit to activate the security feature.
Note: Toggling a bit means changing it from to or from to
Input Specification:
input: An integer value N representing the current binary key configuration input: An integer value B representing the bit position to toggle for activating the security feature
Output Specification:
Return an integer value representing the updated binary key configuration after toggling the Nih bit to activate the security feature.
Example :
input:
input:
Output :
Explanation:
Here, N and B The binary representation of is Toggling the rd bit
results in which is equivalent to in decimA notation. Hence, is returned as the output.
Example : input:
input:
Output :
Explanation:
Here, N and B The binary representation of is Toggling the nd bit
results in which is equivalent to in decimal notation. Hence, is returned as the output.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
