mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-08 20:16:30 +08:00
build
This commit is contained in:
@@ -238,14 +238,6 @@ comments: true
|
||||
[class]{}-[func]{permutations_i}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="permutations_i.zig"
|
||||
[class]{}-[func]{backtrack}
|
||||
|
||||
[class]{}-[func]{permutationsI}
|
||||
```
|
||||
|
||||
## 13.2.2 重複要素を考慮する場合
|
||||
|
||||
!!! question
|
||||
@@ -467,14 +459,6 @@ comments: true
|
||||
[class]{}-[func]{permutations_ii}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="permutations_ii.zig"
|
||||
[class]{}-[func]{backtrack}
|
||||
|
||||
[class]{}-[func]{permutationsII}
|
||||
```
|
||||
|
||||
すべての要素が異なると仮定すると、$n$ 個の要素の順列は $n!$ (階乗)個あります。各結果を記録するには長さ $n$ のリストをコピーする必要があり、これには $O(n)$ 時間がかかります。**したがって、総時間計算量は $O(n!n)$ です。**
|
||||
|
||||
最大再帰深度は $n$ で、$O(n)$ のスタック空間を使用します。`selected` 配列も $O(n)$ 空間が必要です。一度に最大 $n$ 個の個別の `duplicated` セットが存在する可能性があるため、それらは集合的に $O(n^2)$ 空間を占有します。**したがって、空間計算量は $O(n^2)$ です。**
|
||||
|
||||
Reference in New Issue
Block a user