Simplest solution ever in O(1)

int Solution::solve(int A) {
for(int i=0;i<31;i++)
{
if((A>>i)&1)
return i;
}
return 31;
}

Click here to start solving coding interview questions