How do you reverse the bits between j to k in a 32 bit integer.

For e.g.:

n = 11100011;  j = 2 and k =  5
output: 11011111  (bits from 2 to 5 are reversed.)

n = 11010110; j = 1 and k = 5
output: 11101000

O(1) method is preferred.
Thanks,
-- 
Dinesh Bansal
The Law of Win says, "Let's not do it your way or my way; let's do it
the best way."

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to