Skip to content

Commit 1e61316

Browse files
authored
Merge pull request #780 from bus710/week03
[bus710] week 03
2 parents dfd507b + 64d6240 commit 1e61316

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

two-sum/bus710.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// O(n/2) as we only visit the half of the i*j
2+
3+
package hello
4+
5+
func twoSum(nums []int, target int) []int {
6+
for i := range nums {
7+
for j := i + 1; j < len(nums); j++ {
8+
if (nums[i] + nums[j]) == target {
9+
return []int{i, j}
10+
}
11+
}
12+
}
13+
14+
return nil
15+
}

0 commit comments

Comments
 (0)