Add Binary Solution In C++/Java/Python/JS Problem Description Given two binary strings a and b, return their sum as a binary string. Example Input: a = "11", b = "1" Output: "100" Input: a = "1010", b = "1011" Output: "10101" Constraints * 1 <= a.length, b.length
Number of 1 Bits Solution In C++/Java/Python/JS Problem Description Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight). What are Set Bits in Binary Representation? In binary, a set bit is simply a bit whose value is 1. For example, if
Number Complement Solution In C++/Java/Python/JS Problem Description The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and
Set the Rightmost Unset Bit Solution In C++/Java/Python/JS Problem Description Given a non-negative number n. The problem is to set the rightmost unset bit in the binary representation of n. What is Set/Unset Bit? What is a Bit? In binary, every number is made of bits — and each bit can either be 0 or 1. These are
Check Odd or Even Solution In C++/Java/Python/JS Problem Description Given a positive integer n, determine whether it is odd or even. Return true if the number is even and false if the number is odd. Example Input: n = 15 Output: false Explanation: The number is not divisible by 2, Odd number. Input: n = 44 Output: true Explanation:
Kth Bit is Set or Not Solution In C++/Java/Python/JS Problem Description Given two positive integer n and k, check if the kth index bit of n is set or not. What is a Kth Bit and Set Bit? What is the k-th bit? Every number in binary is made up of bits (0s and 1s). These bits are like
Get, Set, Clear ith Bit Solution In C++/Java/Python/JS Problem Description Given a 32 bit unsigned integer num and an integer i. Perform following operations on the number - 1. Get i-th bit 2. Set i-th bit 3. Clear i-th bit Note : For better understanding, we are starting bits from 1 instead 0. (1-based). You have to print space
Decimal to Binary Solution In C++/Java/Python/JS Problem Description Given a decimal number n, return its binary equivalent. What is Binary Representation of a Number? Binary representation of a number is a way of expressing it using only two digits: 0 and 1. Each digit represents a power of 2, starting from the right (least significant bit)
Coming Soon.. Hold tight! Our team is working on more articles. We're constantly trying to bring new articles every week.