def solution(num: str) -> int:
l = len(num)
if l >= 5:
max = int(num[:5])
for i in range(l-4):
if int(num[i:i+5]) > max:
max = int(num[i:i+5])
return max
def solution(num: str) -> int:
# your code here
nums = num[:-4]
for i in range(9, -1, -1):
count = nums.count(str(i))
c = [-1]
for j in range(count):
c.append(nums.find(str(i), c[j] + 1, len(nums)))
h = []
if len(c) > 1:
for i in c:
if i != -1:
h.append(int(num[i: i + 5]))
if h:
return max(h)
return ''
assert solution("12345678909999999999") == 99999
assert solution("1234567898765") == 98765
assert solution("731674765") == 74765
def solution(num: str) -> int:
# 找出最大的数字N
num_list = [int(n) for n in num[:-4]]
max_digit = max(num_list)
# 找出N****,返回最大值,即为结果
list_competor = []
for i in range(len(num_list)):
if num_list[i] == max_digit:
list_competor.append(int(num[i:i+5]))
return max(list_competor)
def solution(num: str)-> int:
# result=[]
# for i in range(len(num)-4):
# result.append(num[i:i+5])
# return int(sorted(result,key=int)[-1])
return max(int(num[i:i+5]) for i in range(len(num) - 4))