Posts

Showing posts from December, 2022

TWO TEST BINARY SEARCH to ONE TEST BINARY SEARCH

Image
 Below is the code for binary search function with 1 tests in while loop => I have converted the condition which ends the while loop to outside of while as shown in images.

191.Number Of 1 Bits

 Problem link => https://leetcode.com/problems/number-of-1-bits/ Code link => https://github.com/booleanbug/75-LeetCode/new/main Logic =>     First understand the unsigned format like uint8_t,uint16_t,uint32_t,uint64_t. Then right shift the number and take & with one,so that you can see whether that bit is 1 or 0 then add it to final answer.   SIMPLE QUESTION.