From 54ced94e4f5287bb33112a37e3af3d3a0e5d9879 Mon Sep 17 00:00:00 2001 From: huangjikun <72253502+xiaomiusa87@users.noreply.github.com> Date: Mon, 22 Apr 2024 02:28:54 +0800 Subject: [PATCH] Fix incorrect indexes in two_sum.go (#1297) --- codes/go/chapter_searching/two_sum.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/go/chapter_searching/two_sum.go b/codes/go/chapter_searching/two_sum.go index 922a4100c..565540d4b 100644 --- a/codes/go/chapter_searching/two_sum.go +++ b/codes/go/chapter_searching/two_sum.go @@ -9,7 +9,7 @@ func twoSumBruteForce(nums []int, target int) []int { size := len(nums) // 两层循环,时间复杂度为 O(n^2) 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 { return []int{i, j} }