Skip to content

Commit

Permalink
Fix incorrect indexes in two_sum.go (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomiusa87 committed Apr 21, 2024
1 parent f616dac commit 54ced94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion codes/go/chapter_searching/two_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down

0 comments on commit 54ced94

Please sign in to comment.