diff --git a/problems/0093.复原IP地址.md b/problems/0093.复原IP地址.md index 55e57dde..59cd92da 100644 --- a/problems/0093.复原IP地址.md +++ b/problems/0093.复原IP地址.md @@ -40,16 +40,12 @@ * 0 <= s.length <= 3000 * s 仅由数字组成 -# 算法公开课 +## 算法公开课 -**《代码随想录》算法视频公开课:[93.复原IP地址](https://www.bilibili.com/video/BV1XP4y1U73i/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 - -# 算法公开课 - -**《代码随想录》算法视频公开课:[回溯算法如何分割字符串并判断是合法IP?| LeetCode:93.复原IP地址](https://www.bilibili.com/video/BV1XP4y1U73i/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[回溯算法如何分割字符串并判断是合法IP?| LeetCode:93.复原IP地址](https://www.bilibili.com/video/BV1XP4y1U73i/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 -# 思路 +## 思路 做这道题目之前,最好先把[131.分割回文串](https://programmercarl.com/0131.分割回文串.html)这个做了。 @@ -63,7 +59,7 @@ ![93.复原IP地址](https://code-thinking-1253855093.file.myqcloud.com/pics/20201123203735933.png) -## 回溯三部曲 +### 回溯三部曲 * 递归参数 @@ -134,7 +130,7 @@ for (int i = startIndex; i < s.size(); i++) { } ``` -## 判断子串是否合法 +### 判断子串是否合法 最后就是在写一个判断段位是否是有效段位了。 @@ -169,8 +165,6 @@ bool isValid(const string& s, int start, int end) { } ``` -## C++代码 - 根据[关于回溯算法,你该了解这些!](https://programmercarl.com/回溯算法理论基础.html)给出的回溯算法模板: @@ -247,7 +241,7 @@ public: * 时间复杂度: O(3^4),IP地址最多包含4个数字,每个数字最多有3种可能的分割方式,则搜索树的最大深度为4,每个节点最多有3个子节点。 * 空间复杂度: O(n) -# 总结 +## 总结 在[131.分割回文串](https://programmercarl.com/0131.分割回文串.html)中我列举的分割字符串的难点,本题都覆盖了。 @@ -259,9 +253,9 @@ public: -# 其他语言版本 +## 其他语言版本 -## java +### Java ```java class Solution { @@ -402,7 +396,7 @@ class Solution { ``` -## python +### Python 回溯(版本一) ```python @@ -478,9 +472,7 @@ class Solution: ``` - - -## Go +### Go ```go var ( @@ -517,7 +509,7 @@ func dfs(s string, start int) { } ``` -## JavaScript +### JavaScript ```js /** @@ -547,7 +539,7 @@ var restoreIpAddresses = function(s) { }; ``` -## TypeScript +### TypeScript ```typescript function isValidIpSegment(str: string): boolean { @@ -586,7 +578,7 @@ function restoreIpAddresses(s: string): string[] { }; ``` -## Rust +### Rust ```Rust impl Solution { @@ -643,7 +635,7 @@ impl Solution { } ``` -## C +### C ```c //记录结果 char** result; @@ -719,7 +711,7 @@ char ** restoreIpAddresses(char * s, int* returnSize){ } ``` -## Swift +### Swift ```swift // 判断区间段是否合法 @@ -766,7 +758,7 @@ func restoreIpAddresses(_ s: String) -> [String] { } ``` -## Scala +### Scala ```scala object Solution { @@ -813,3 +805,4 @@ object Solution { +