更新 0093.复原IP地址 排版格式修复

This commit is contained in:
jinbudaily
2023-07-24 14:11:47 +08:00
parent 7bd8751a0c
commit 6f711891ba

View File

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