zoukankan      html  css  js  c++  java
  • 【leetcode❤python】 38. Count and Say

    #-*- coding: UTF-8 -*-
    class Solution(object):
        def countAndSay(self, n):
            """
            :type n: int
            :rtype: str
            """
            n=n-1
            if n==0:return str(1)
            tag=1;stri=str(11)
            while tag<n:
                cur=stri;j=0
                tmps=''
                while j<len(cur):
                    count=1;m=j+1
                    while m<len(cur):
                        if cur[j]==cur[m]:
                            count+=1;m+=1
                        else:break
                    tmp=str(count)+str(cur[j])
                    j=m

                    tmps+=tmp
                stri=tmps;tag+=1
            return stri

    sol=Solution()
    print sol.countAndSay(6)

                        
                    
                    
               

  • 相关阅读:
    阅读大道至简的读后感
    暑期第四周学习总结
    暑假学期第三周总结
    暑期学习第二周总结
    kuangbin专题 小希的迷宫
    Exam 5095 Hopscotch
    Exam 5431 //Barareh on Fire
    4.19 手写简单循环队列与栈
    web安全:xss && csrf
    web安全:HTTPS
  • 原文地址:https://www.cnblogs.com/kwangeline/p/6059538.html
Copyright © 2011-2022 走看看