Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- class Solution(object):
- def countAndSay(self, n):
- """
- :type n: int
- :rtype: str
- """
- s = '1'
- for _ in range(0, n-1):
- ls = []
- for digit, group in itertools.groupby(s):
- temp = len(list(group))
- temp = str(temp) + digit
- ls.append(temp)
- s = ''.join(ls)
- return s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement