Tuesday, May 24, 2016

Algorithm: check if the number is power of 2

May 24, 2016

Fun part:
10 ways to check if the number is power of 2
http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/

10 solutions:
https://gist.github.com/jianminchen/410d19acf623a7e2a4a349ccd8767c1e

add comment and test case for solution 7: count ones:
https://gist.github.com/jianminchen/1035e23fd6117ba7daa38476596e2784

Plan to spend hours to go over the blog:
1. http://graphics.stanford.edu/~seander/bithacks.html
2. http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2

3. http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/


Review following algorithms:

1. LeetCode 29     Divide Two Integer
2. Leetcode 124:   Binary tree max path sum (Hard)
3. Leetcode 126:   word ladder II (Hard)
4. Leetcode 127:   word ladder (Medium)
5. LeetCode 159:   Longest Substring with At Most Two Distinct Characters
6. Leetcode 252:   meeting room
7. Leetcode 253:   meeting room 2

8. find first repeated word in a string

10. Given a dictionary of words and a word, return the word if it exists in dict, else return the top 5 words in the dict that are closest to the given word
11. http://www.geeksforgeeks.org/dynamic-programming-set-32-word-break-problem/
12. http://articles.leetcode.com/double-square-problem-analysis/
13. Design a parking Lot.

No comments:

Post a Comment