输出一个字符串中连续出现三次以上的数字字符(多解的话输出最大的数字),水题
1 #2264
2 #Runtime: 17 ms (Beats 71.79%)
3 #Memory: 13.4 MB (Beats 46.15%)
4
5 class Solution(object):
6 def largestGoodInteger(self, num):
7 """
8 :type num: str
9 :rtype: str
10 """
11 x = '/'
12 t = 1
13 for i in xrange(1, len(num)):
14 if num[i] == num[i - 1]:
15 t += 1
16 if t >= 3:
17 x = max(x, num[i])
18 print(x)
19 else:
20 t = 1
21 if x >= '0':
22 return x * 3
23 return ""