LinkedIn interview question

Question on string compression on hackerrank