尝试更改此:
if len(set(substr)) != (end - start): # found duplicates or EOS
break
if (ord(max(sorted(substr))) - ord(min(sorted(substr))) + 1) == len(substr):
对此:
if len(substr) != (end - start): # found duplicates or EOS
break
if sorted(substr) == list(substr):