diff --git a/two-sum/bus710.go b/two-sum/bus710.go new file mode 100644 index 000000000..7542c9f1e --- /dev/null +++ b/two-sum/bus710.go @@ -0,0 +1,15 @@ +// O(n/2) as we only visit the half of the i*j + +package hello + +func twoSum(nums []int, target int) []int { + for i := range nums { + for j := i + 1; j < len(nums); j++ { + if (nums[i] + nums[j]) == target { + return []int{i, j} + } + } + } + + return nil +}