leetcode -- Count and Say -- 理解题意

https://leetcode.com/problems/count-and-say/

重点在理解题意。count and say

class Solution(object):
    def countAndSay(self, n):
        """
        :type n: int
        :rtype: str
        """
        if n == 1:
            return "1"
        else:
            last = self.countAndSay(n - 1)
            digit,count = last[0], 0
            res = ""
            for i in xrange(len(last)):

                if last[i] != digit:
                    res += str(count) + str(digit)
                    digit = last[i]
                    count = 1
                else:
                    count += 1
            return res + str(count) + str(digit)