https://leetcode.com/problems/number-of-1-bits/
Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).
For example, the 32-bit integer ’11’ has binary representation 0000000000000…
https://leetcode.com/problems/counting-bits/
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.
Example: For num 5 you should …
https://leetcode.com/problems/add-binary/
Given two binary strings, return their sum (also a binary string).
For example, a “11” b “1” Return “100”.
计算过程类似Verilog的全加器。
char* addBinary(char* a, char* b) {int i;int l1, l2, l3, temp;…
https://leetcode.com/problems/power-of-three/
Given an integer, write a function to determine if it is a power of three.
Follow up: Could you do it without using any loop / recursion?
3的次方数没有显著的特点,最直接的方法就是不停地除以3&…