compress the string hackerrank solution