更新 组合优化 排版格式修复

This commit is contained in:
jinbudaily
2023-07-24 11:02:27 +08:00
parent 6f3fdf7286
commit f5e50a919d

View File

@ -7,8 +7,11 @@
# 77.组合优化
## 算法公开课
**《代码随想录》算法视频公开课:[组合问题的剪枝操作](https://www.bilibili.com/video/BV1wi4y157er),相信结合视频在看本篇题解,更有助于大家对本题的理解**
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[组合问题的剪枝操作](https://www.bilibili.com/video/BV1wi4y157er),相信结合视频在看本篇题解,更有助于大家对本题的理解**
## 思路
在[回溯算法:求组合问题!](https://programmercarl.com/0077.组合.html)中我们通过回溯搜索法解决了n个数中求k个数的组合问题。
@ -46,7 +49,7 @@ public:
};
```
# 剪枝优化
## 剪枝优化
我们说过,回溯法虽然是暴力搜索,但也有时候可以有点剪枝优化一下的。
@ -135,7 +138,7 @@ public:
# 总结
## 总结
本篇我们针对求组合问题的回溯法代码做了剪枝优化,这个优化如果不画图的话,其实不好理解,也不好讲清楚。
@ -143,14 +146,10 @@ public:
**就酱学到了就帮Carl转发一下吧让更多的同学知道这里**
## 其他语言版本
### Java
Java
```java
class Solution {
List<List<Integer>> result = new ArrayList<>();
@ -179,7 +178,8 @@ class Solution {
}
```
Python
### Python
```python
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
@ -199,7 +199,8 @@ class Solution:
```
Go
### Go
```Go
var (
path []int
@ -227,7 +228,7 @@ func dfs(n int, k int, start int) {
}
```
javaScript:
### JavaScript
```js
var combine = function(n, k) {
@ -249,7 +250,7 @@ var combine = function(n, k) {
};
```
TypeScript
### TypeScript
```typescript
function combine(n: number, k: number): number[][] {
@ -270,7 +271,7 @@ function combine(n: number, k: number): number[][] {
};
```
Rust:
### Rust
```Rust
impl Solution {
@ -296,7 +297,7 @@ impl Solution {
}
```
C:
### C
```c
int* path;
@ -351,7 +352,7 @@ int** combine(int n, int k, int* returnSize, int** returnColumnSizes){
}
```
Swift
### Swift
```swift
func combine(_ n: Int, _ k: Int) -> [[Int]] {
@ -381,7 +382,7 @@ func combine(_ n: Int, _ k: Int) -> [[Int]] {
}
```
Scala:
### Scala
```scala
object Solution {
@ -414,3 +415,4 @@ object Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>