Amazon interview question

Given a decoder, design the encoder