Can we xor between 2 number and then return set bit position is it right?
@djs9patna3 жыл бұрын
Why in third loop you have taken as while(i
@younisthetrainer84612 жыл бұрын
how you know length of bit string is 10
@rajendralnct4 жыл бұрын
#include #include using namespace std; //Toggle bits in range and include int toggleBit(int n, int l, int r) { while(l
@avisheksinha42645 жыл бұрын
Thanks for all the videos sir.. Btw you are from Durgapur,West Bengal??
@techdose4u5 жыл бұрын
Yea right.....Durgapur, WB.
@avisheksinha42645 жыл бұрын
@@techdose4u sir I Am from Asansol.Please tell if you provide any tuition classes.If any please let me know sir.
@techdose4u5 жыл бұрын
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 :)
@avisheksinha42645 жыл бұрын
@@techdose4u ok sir.Your videos helps us a lot.Thank you😀
@damercy4 жыл бұрын
@@techdose4u I'm from Durgapur as well! Awesome! Do you mind saying which area? I'm from A-zone.
@krishnakapoor69113 жыл бұрын
WAP to toggle/compliment first n bits which are multiple of m from position p for given number.
@AmanKumar-xw5kl5 жыл бұрын
Can be solved using xor and
@techdose4u5 жыл бұрын
Yea correct. You can use AND or XOR. Both are correct.
@manikanta67614 жыл бұрын
Thanks for making this video .But the answer in the last was 23
@vishwastyagi27705 жыл бұрын
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
@techdose4u5 жыл бұрын
Will see and solve your questions once I reach my city :)
@vishwastyagi27705 жыл бұрын
@@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.
@ayushgarg59295 жыл бұрын
@@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
@vishwastyagi27705 жыл бұрын
@@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 Жыл бұрын
Simple code : int exp = R-L+1; int mask = pow(2,exp)-1; mask = mask
@vijayknaikwadi23114 жыл бұрын
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)
@abhaytiwari64115 жыл бұрын
bro can you make video on time complexity before 31 january
@techdose4u5 жыл бұрын
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.
@KasibuorLaBelva2 жыл бұрын
Q1 perfectly defined
@priyankapardesiramachander8713 жыл бұрын
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; }