solution for reverse binary