更新0093.复原IP地址python3版本,添加剪枝操作

This commit is contained in:
ironartisan
2021-08-24 16:15:36 +08:00
parent b570233409
commit 649fe7a202

View File

@ -328,6 +328,7 @@ class Solution:
return
for i in range(startIndex, len(s)):
if len(s) - startIndex > 3*(4 - len(path)): continue # 剪枝,剩下的字符串大于允许的最大长度则跳过
p = s[startIndex:i+1] # 分割字符
if isValid(p): # 判断字符是否有效
path.append(p)