Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.05 KB

0093-restore-ip-addresses.adoc

File metadata and controls

40 lines (26 loc) · 1.05 KB

93. Restore IP Addresses

{leetcode}/problems/restore-ip-addresses/[LeetCode - Restore IP Addresses^]

Given a string containing only digits, restore it by returning all possible valid IP address combinations.

Example:
Input: "25525511135"
Output: ["255.255.11.135", "255.255.111.35"]

解题分析

使用回溯,每次做一次字符串切割,如果切割的字符串符合 IP 的大小值,则前进一步,直到把字符串切割完毕并且正好切割四份。

{image_attr}

参考资料

Given a string containing only digits, restore it by returning all possible valid IP address combinations.

Example:

Input: "25525511135"
Output: ["255.255.11.135", "255.255.111.35"]
link:{sourcedir}/_0093_RestoreIPAddresses.java[role=include]