Merge pull request #2109 from Logenleedev/local-edit

添加复杂度分析
This commit is contained in:
程序员Carl
2023-06-14 09:16:27 +08:00
committed by GitHub

View File

@ -98,6 +98,8 @@ public:
} }
}; };
// 时间复杂度: 最差情况所有元素都是唯一的。复杂度和全排列1都是 O(n! * n) 对于 n 个元素一共有 n! 中排列方案。而对于每一个答案,我们需要 O(n) 去复制最终放到 result 数组
// 空间复杂度: O(n) 回溯树的深度取决于我们有多少个元素
``` ```
* 时间复杂度: O(n) * 时间复杂度: O(n)
* 空间复杂度: O(n) * 空间复杂度: O(n)