This commit is contained in:
krahets
2023-02-09 04:43:12 +08:00
parent af3542e3c0
commit 4d2575be7a
18 changed files with 264 additions and 156 deletions
@@ -80,6 +80,7 @@ comments: true
=== "Go"
```go title="leetcode_two_sum.go"
/* 方法一:暴力枚举 */
func twoSumBruteForce(nums []int, target int) []int {
size := len(nums)
// 两层循环,时间复杂度 O(n^2)
@@ -257,6 +258,7 @@ comments: true
=== "Go"
```go title="leetcode_two_sum.go"
/* 方法二:辅助哈希表 */
func twoSumHashTable(nums []int, target int) []int {
// 辅助哈希表,空间复杂度 O(n)
hashTable := map[int]int{}