Python极简无需双指针,滑动窗口即可(因为固定了K):
class Solution:
def maxValue(self , s , k ):
l = res = 0
while l < len(s) and l+k <= len(s): #判断不超过索引
if int(s[l:l+k]) > int(res):
res = s[l:l+k]
l += 1
return int(res)