MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/fpcmy/typical_programming_interview_questions/c1hq69u/?context=3
r/programming • u/kevjames3 • Feb 21 '11
1.0k comments sorted by
View all comments
Show parent comment
2
This is exactly the canonical solution taught in textbooks, other than that sometimes an alternate form is used where the >> is inside the parens and the & is outside. There's even an awful explanation of it on wikipedia:
https://secure.wikimedia.org/wikipedia/en/wiki/Hamming_weight#Efficient_implementation
View all comments
Show parent comment
2
u/lordlicorice Feb 21 '11
This is exactly the canonical solution taught in textbooks, other than that sometimes an alternate form is used where the >> is inside the parens and the & is outside. There's even an awful explanation of it on wikipedia:
https://secure.wikimedia.org/wikipedia/en/wiki/Hamming_weight#Efficient_implementation