mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-15 21:20:58 +00:00
build
This commit is contained in:
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user