# LeetCode 338. Counting Bits

Description https://leetcode.com/problems/counting-bits/ Given an integer n, return an array ans of length n + 1 such that for each i(0 <= i <= n), ans[i] is the number of 1‘s in the…

# LeetCode 762. Prime Number of Set Bits in Binary Representation

Description https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/ Given two integers left and right, find the count of numbers in the range [left, right] (inclusive) having a prime number of set…

# LeetCode 693. Binary Number with Alternating Bits

Description https://leetcode.com/problems/binary-number-with-alternating-bits/ Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have…

# LeetCode 1720. Decode XORed Array

Description https://leetcode.com/problems/decode-xored-array/ There is a hidden integer array arr that consists of n non-negative integers. It was encoded into another integer array encoded of length n – 1, such…

# LeetCode 1018. Binary Prefix Divisible By 5

Description https://leetcode.com/problems/binary-prefix-divisible-by-5/ Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.) Return a…

Description https://leetcode.com/problems/add-binary/ Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = “11”, b =…

# LeetCode 1356. Sort Integers by The Number of 1 Bits

Description https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits/ Given an integer array arr. You have to sort the integers in the array in ascending order by the number…

# LeetCode 868. Binary Gap

Description https://leetcode.com/problems/binary-gap/ Given a positive integer n, find and return the longest distance between any two adjacent 1‘s in the binary representation of n. If there are…

# LeetCode 1009. Complement of Base 10 Integer

Description https://leetcode.com/problems/complement-of-base-10-integer/ Every non-negative integer N has a binary representation.  For example, 5 can be represented as “101” in binary, 11 as “1011” in binary, and so on.  Note that…

# LeetCode 476. Number Complement

Description https://leetcode.com/problems/number-complement/ Given a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation.…