Toggle bits in a given range

  Рет қаралды 11,590

Techdose

Techdose

Күн бұрын

Пікірлер: 29
@zskhan7496
@zskhan7496 2 жыл бұрын
Can we xor between 2 number and then return set bit position is it right?
@djs9patna
@djs9patna 3 жыл бұрын
Why in third loop you have taken as while(i
@younisthetrainer8461
@younisthetrainer8461 2 жыл бұрын
how you know length of bit string is 10
@rajendralnct
@rajendralnct 4 жыл бұрын
#include #include using namespace std; //Toggle bits in range and include int toggleBit(int n, int l, int r) { while(l
@avisheksinha4264
@avisheksinha4264 5 жыл бұрын
Thanks for all the videos sir.. Btw you are from Durgapur,West Bengal??
@techdose4u
@techdose4u 5 жыл бұрын
Yea right.....Durgapur, WB.
@avisheksinha4264
@avisheksinha4264 5 жыл бұрын
@@techdose4u sir I Am from Asansol.Please tell if you provide any tuition classes.If any please let me know sir.
@techdose4u
@techdose4u 5 жыл бұрын
I am working in Bengaluru. So, you can take help only from my videos. If you face any problem then let me know. I will help you :)
@avisheksinha4264
@avisheksinha4264 5 жыл бұрын
@@techdose4u ok sir.Your videos helps us a lot.Thank you😀
@damercy
@damercy 4 жыл бұрын
@@techdose4u I'm from Durgapur as well! Awesome! Do you mind saying which area? I'm from A-zone.
@krishnakapoor6911
@krishnakapoor6911 3 жыл бұрын
WAP to toggle/compliment first n bits which are multiple of m from position p for given number.
@AmanKumar-xw5kl
@AmanKumar-xw5kl 5 жыл бұрын
Can be solved using xor and
@techdose4u
@techdose4u 5 жыл бұрын
Yea correct. You can use AND or XOR. Both are correct.
@manikanta6761
@manikanta6761 4 жыл бұрын
Thanks for making this video .But the answer in the last was 23
@vishwastyagi2770
@vishwastyagi2770 5 жыл бұрын
Hi Team, Thanks for this video. Could you please make video on 2 questions which I faced in an interview. Question 1. Rearrange given array in such a way such that no two consecutive numbers are divisible by 3. Question 2. Given a binary array(array which contains 0 and 1 only, example [0,1,1,0,0,1]), and m(say m=3) and k(say k=10) as integers. Now iterate from 1 to m and on each iteration modify binary array in such way that replace 0 with 0 and 1 and 1 with 1 and 0 . After completing m iteration, find the element at kth index. For example if input array is [0,1,1] and m=1 and k=4 then on the first iteration array will be modified to [0,1,1,0,1,0]. Element at kth position is 0, hence output will be 0 (starting indexing being 1). Hope my questions are clear. Thanks
@techdose4u
@techdose4u 5 жыл бұрын
Will see and solve your questions once I reach my city :)
@vishwastyagi2770
@vishwastyagi2770 5 жыл бұрын
@@techdose4u Thanks, I was able to solve both questions but space and time complexity was not good. Interviewer was expecting better/efficient approach. So I want to learn efficient algorithm for both questions.
@ayushgarg5929
@ayushgarg5929 5 жыл бұрын
@@vishwastyagi2770 your first question can be solved as firstly find out all the elements from the array that are divisible by 3.. then try to put the other remaining elements between them
@vishwastyagi2770
@vishwastyagi2770 5 жыл бұрын
​@@ayushgarg5929 I solved both the questions, but the interviewer was not satisfied with the answers. For the first question, I used the same approach as you are telling. This is a very obvious approach
@sauravchandra10
@sauravchandra10 Жыл бұрын
Simple code : int exp = R-L+1; int mask = pow(2,exp)-1; mask = mask
@vijayknaikwadi2311
@vijayknaikwadi2311 4 жыл бұрын
Can we say O(log n) is nearly equal to O(1) As the question in gfg they expect the complexity to be O(1) Or else is there any way to solve it in O(1)
@abhaytiwari6411
@abhaytiwari6411 5 жыл бұрын
bro can you make video on time complexity before 31 january
@techdose4u
@techdose4u 5 жыл бұрын
Guaranteed. Remind me once after 10th if i don't upload. Do you want to see video on details of calculating Time complexity? With some good examples? I hope if i explain with examples then it will be better.
@KasibuorLaBelva
@KasibuorLaBelva 2 жыл бұрын
Q1 perfectly defined
@priyankapardesiramachander871
@priyankapardesiramachander871 3 жыл бұрын
int ToggleRangeBits(int n, int left, int right) { int mask = pow(2, right -1) - 1; mask = mask - pow(2, left -1) - 1; return n ^ mask; }
@techdose4u
@techdose4u 3 жыл бұрын
👍🏼
Check if Kth bit is set or not
3:34
Techdose
Рет қаралды 12 М.
How to set and clear a bit
8:39
Pankaj prasad
Рет қаралды 26 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Toggle Bits in the given range | Bit Manipulation
6:06
McaupyBugs
Рет қаралды 1 М.
Find rightmost different bit between 2 numbers
6:21
Techdose
Рет қаралды 7 М.
Toggle I'th bit of a given number
4:04
CppNuts
Рет қаралды 3,4 М.
Grid Game | Leetcode 2017
21:51
Techdose
Рет қаралды 3,8 М.
Bit Fields in C. What are they, and how do I use them?
13:26
Jacob Sorber
Рет қаралды 86 М.
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
GFG POTD: 20/09/2023 | Rotate Bits | Problem of the Day GeeksforGeeks
16:20
GeeksforGeeks Practice
Рет қаралды 719
Find rightmost set bit efficiently
7:30
Techdose
Рет қаралды 25 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН