Toggle bits in a given range
Vložit
- čas přidán 2. 01. 2020
- This video explains how to toggle bits in a given range. Given a number, we are required to change 0 to 1 and 1 to 0 within a given range of binary representation of the number. The solution explained is efficient and works in O(logN). CODE LINK is given below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
CODE LINK: gist.github.com/SuryaPratapK/...
Use this :- (1<
Can we xor between 2 number and then return set bit position is it right?
Why in third loop you have taken as while(i<=10) , it should not be i
Thanks for the video.
#include
Thanks for making this video .But the answer in the last was 23
Can be solved using xor and << as well
WAP to toggle/compliment first n bits which are multiple of m from position p for given number.
Thanks for all the videos sir..
how you know length of bit string is 10
Q1 perfectly defined
Can we say
Hi Team, Thanks for this video. Could you please make video on 2 questions which I faced in an interview.
Simple code :
bro can you make video on time complexity before 31 january
Here is a python code using xor
int ToggleRangeBits(int n, int left, int right)