We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 163ad4d commit e5d47eeCopy full SHA for e5d47ee
Count and Say/Count_and_Say.py
@@ -0,0 +1,35 @@
1
+# 40ms 90.52%
2
+class Solution:
3
+ def countAndSay(self, n):
4
+ """
5
+ :type n: int
6
+ :rtype: str
7
8
+ def count(strs):
9
+ res = ''
10
+ index = 0
11
+ len_strs = len(strs)
12
+
13
+ while index < len_strs:
14
+ num = 1
15
+ letter = strs[index]
16
17
18
+ index += 1
19
+ if index >= len_strs:
20
+ res += (str(num) + letter)
21
+ break
22
23
+ if strs[index] == letter:
24
+ num += 1
25
+ else:
26
27
28
+ return res
29
30
+ for i in range(n):
31
+ if i is 0:
32
+ temp = '1'
33
34
+ temp = count(temp)
35
+ return temp
0 commit comments