Posted by: sabbour on: July 24, 2008
I got asked this question during an interview last week. I think I gave a wrong answer in the interview but I decided I needed to find the correct answer! I searched and found this solution which involved bit manipulations, though I didn’t find it intuitive.
I came up with this simple solution
public class PowerOfTwo {
public [...]