python leetcode 93. Restore IP Addresses
又是DFS
class Solution(object):
def restoreIpAddresses(self, s):
"""
:type s: str
:rtype: List[str]
"""
self.res=set()
def help(s1,s2,k):
if s2=="" and k==0:
return self.res.add(s1[:-1])
if k<=0 or s2=="":
return
for i in range(1,4):
if 0<=int(s2[:i])<=255:
if len(s2[:i])>1 and s2[0]=='0':
break
help(s1+s2[:i]+'.',s2[i:],k-1)
help("",s,4)
return list(self.res)
相關文章
- [LeetCode] 93. Restore IP AddressesLeetCodeREST
- Leetcode Restore IP AddressesLeetCodeREST
- Restore IP Addresses leetcode javaRESTLeetCodeJava
- Leetcode-Resotre IP AddressesLeetCode
- 「leetcode」93.復原IP地址【回溯演算法】詳解!LeetCode演算法
- LeetCode之Unique Email Addresses(Kotlin)LeetCodeAIKotlin
- [AlwaysOn2017] AlwaysOn的DMV和DMF -Sys.availability_group_listener_ip_addressesAI
- guarantee restore points-Flashback after RMAN restoreREST
- canvas restore()CanvasREST
- RESTORE POINTREST
- [LeetCode] Validate IP AddressLeetCode
- 程式碼隨想錄演算法訓練營第24天 | 93.復原IP地址 78.子集 90.子集Ⅱ演算法
- Restore ArchivelogRESTHive
- LeetCode-093-復原 IP 地址LeetCode
- DOCKER特性 - LIVE RESTOREDockerREST
- canvas save()和restore()CanvasREST
- SQL Server Backup & RestoreSQLServerREST
- How restore CBO statisticsREST
- TFS Express backup and restoreExpressREST
- backup and restore tipsREST
- TMS request queue restoreREST
- python爬蟲從ip池獲取隨機IPPython爬蟲隨機
- Restore Points 制定回退方案REST
- restore和recover 區別REST
- restore database check readonlyRESTDatabase
- rman restore archivelog logRESTHive
- restore,recover的區別REST
- Cold backup and restore the entire databaseRESTDatabase
- How to restore ASM based OCRRESTASM
- [leetcode]Gas Station @ PythonLeetCodePython
- 05.python requests IP代理Python
- DBMS_BACKUP_RESTORE.DBMS_BACKUP_RESTORE用於特殊情況下的恢復REST
- git操作之二:git restoreGitREST
- restore、recover到指定時間REST
- oracle 8i的restoreOracleREST
- restore controlfile from autobackREST
- read only tablespace backup restoreREST
- Unable to start HTTP server after restoreHTTPServerREST