Update worst_best_time_complexity,

leetcode_two_sum
This commit is contained in:
Yudong Jin
2023-02-03 18:53:15 +08:00
parent 592965595e
commit 70dead5cd0
24 changed files with 63 additions and 121 deletions

View File

@ -4,7 +4,7 @@
package chapter_computational_complexity
// twoSumBruteForce
/* 方法一:暴力枚举 */
func twoSumBruteForce(nums []int, target int) []int {
size := len(nums)
// 两层循环,时间复杂度 O(n^2)
@ -18,7 +18,7 @@ func twoSumBruteForce(nums []int, target int) []int {
return nil
}
// twoSumHashTable
/* 方法二:辅助哈希表 */
func twoSumHashTable(nums []int, target int) []int {
// 辅助哈希表,空间复杂度 O(n)
hashTable := map[int]int{}