Find position of set bit gfg | GeeksforGeeks problem of the day | Bit Manipulation Basic

  Рет қаралды 6,620

Code with Alisha

Code with Alisha

Күн бұрын

Пікірлер: 9
@probabilitycodingisfunis1
@probabilitycodingisfunis1 2 жыл бұрын
Code C++: if(N==0)return -1; if((N&N-1)==0)return log2(N)+1; return -1;
@24_sanketgolar96
@24_sanketgolar96 2 жыл бұрын
if its having more than one ones in binary log2(N) will not be integer,it will be fraction,is it correct?
@computerandenglish4896
@computerandenglish4896 11 ай бұрын
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
@shivanshsri4072
@shivanshsri4072 2 жыл бұрын
Very good explanation. Thank you soo much😊😊
@jayeshchaurasiya262
@jayeshchaurasiya262 2 жыл бұрын
Love ur explanation ❣️
@indiancseresearch6109
@indiancseresearch6109 2 жыл бұрын
can u plz make video on what is backtracking exactly ? how subset sum is backtracking problem ? when to apply it ? with examples . . . .
@dhananjoydey1337
@dhananjoydey1337 2 жыл бұрын
Thanks
@dhananjoydey1337
@dhananjoydey1337 2 жыл бұрын
Please upload today's problem of the day solution
@rahuldwivedi9236
@rahuldwivedi9236 2 жыл бұрын
BUT WHY?
Find rightmost set bit efficiently
7:30
Techdose
Рет қаралды 25 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 112 МЛН
Чистка воды совком от денег
00:32
FD Vasya
Рет қаралды 6 МЛН
L3. Minimum Bit Flips to Convert Number | Bit Manipulation
7:00
take U forward
Рет қаралды 69 М.
4. 3 ways to count Set Bits | Bit Manipulation | Bharat Singla
14:15
Learn to Code with CodeChef
Рет қаралды 18 М.
How to set and clear a bit
8:39
Pankaj prasad
Рет қаралды 26 М.
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 126 М.
(Neo)Vim Made Me a Better Software Developer
40:27
vim-jp
Рет қаралды 35 М.
Bit Manipulation Series Part 2 || Non Repeating Numbers
17:37
Code with Alisha
Рет қаралды 10 М.
Mini Project: How to program a GPU? | CUDA C/C++
12:53
0Mean1Sigma
Рет қаралды 29 М.