Someone Please explain the difference between these two solutions for Compression Algorithm

@swetankmodi post yours.