Given an unsigned integer x, find the largest y by rearranging the bits in x - MATLAB Cody - MATLAB Central

Problem 108. Given an unsigned integer x, find the largest y by rearranging the bits in x

Difficulty:Rate

Given an unsigned integer x, find the largest y by rearranging the bits in x.

Example:

 Input  x = 10
 Output y is 12

since 10 in binary is 1010 and 12 in binary is 1100.

Solution Stats

62.42% Correct | 37.58% Incorrect
Last Solution submitted on Jun 18, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
1
2

Problem Recent Solvers1898

Suggested Problems

More from this Author100

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!