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…
Be a Good Techer and Tech for Good. www.goodtecher.com
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…
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…
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…
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…
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 =…
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…
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…
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…
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.…