For the binary code above, the lengths are . Thus
This is optimal by Huffman coding.