def compress(self, chars):
        """
        :type chars: List[str]
        :rtype: int
        """
        # https://leetcode.com/problems/string-compression/solution/
        anchor = write = 0
        for read, c in enumerate(chars):
            if read + 1 == len(chars) or chars[read + 1] != c:
                chars[write] = chars[anchor]
                write += 1
                if read > anchor:
                    for digit in str(read - anchor + 1):
                        chars[write] = digit
                        write += 1
                anchor = read + 1
        return write

        :type chars: List[str]
        :rtype: int
        
python/443_String_Compression.py