Need to work on problem solving, AorB, how to design a few simple APIs first?
Write a few function to check bit by bit from right to left, or left to right.
https://gist.github.com/jianminchen/103859e5e8287c9fd865c59363ad500b
A|B = C, to make A as small as possible, with maximum number of bits to update.
For example,
11001000 A
00000000 B
______________
11001000 C
If there are 2 more bits allowed to be update, then to make A smallest as possible, update A's leftmost bit to 0, and update C's leftmost bit to 1.
01001000 A'
10000000 B'
___________
11001000 C
Review blogs related to bit manipulations:
power of 2:
http://juliachencoding.blogspot.ca/2016/05/algorithm-check-if-number-is-power-of-2.html
Blogs to read:
1. Angular 2 minutes review:
http://henriquat.re/intro/
2. So many courses on pluralsight, how to choose courses to learn day by day.
http://app.pluralsight.com/
3. Reading material:
http://web.stanford.edu/class/cs9/
http://web.stanford.edu/class/cs9/lectures/07/Numbers.pdf
https://courses.csail.mit.edu/
No comments:
Post a Comment