mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 03:46:28 +08:00
Fix incorrect indexes in two_sum.go (#1297)
This commit is contained in:
parent
f616dac7da
commit
54ced94e4f
1 changed files with 1 additions and 1 deletions
|
@ -9,7 +9,7 @@ func twoSumBruteForce(nums []int, target int) []int {
|
||||||
size := len(nums)
|
size := len(nums)
|
||||||
// 两层循环,时间复杂度为 O(n^2)
|
// 两层循环,时间复杂度为 O(n^2)
|
||||||
for i := 0; i < size-1; i++ {
|
for i := 0; i < size-1; i++ {
|
||||||
for j := i + 1; i < size; j++ {
|
for j := i + 1; j < size; j++ {
|
||||||
if nums[i]+nums[j] == target {
|
if nums[i]+nums[j] == target {
|
||||||
return []int{i, j}
|
return []int{i, j}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue