how to solve beautiful binary string