ReverseBinary in java and python.