if its having more than one ones in binary log2(N) will not be integer,it will be fraction,is it correct?
@computerandenglish489611 ай бұрын
The algo or formula that you used is basically to find the power of 2. It is not to find the set bit. What if the given no is 7 i.e 111, then your algo would return 2 (which is not the answer). I would like to suggest a answer :- //if number is 0, then there is no set bit if (n == 0) { return -1; // -1 will represent that there is no set bit } //if number is other than 0, then int position = 1; while ((n & 1) != 1 ) { n = n >> 1; position++; //this variable stores the position of the set bit } return position; //here answer will be returned i.e. the position of the set bit
@shivanshsri40722 жыл бұрын
Very good explanation. Thank you soo much😊😊
@jayeshchaurasiya2622 жыл бұрын
Love ur explanation ❣️
@indiancseresearch61092 жыл бұрын
can u plz make video on what is backtracking exactly ? how subset sum is backtracking problem ? when to apply it ? with examples . . . .