Skip to content

Commit 265df64

Browse files
committed
Merge branch '2-sum-updates'
2 parents f0544d0 + c93cc36 commit 265df64

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Two-Sum Problem/README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func twoSumProblem(_ numbers: [Int], target: Int) -> (Int, Int)? {
2626
}
2727
```
2828

29-
The `twoSumProblem()` function takes two parameters: the array `a` with the numbers, and `k`, the sum we're looking for. It returns the first set of indices `(i, j)` where `a[i] + a[j] == k`, or `nil` if no two numbers add up to `k`.
29+
The `twoSumProble` function takes two parameters: the `numbers` array and the target sum you're looking for. It returns the 2 indices with elements that sums up to the target, or `nil` if it can't be found.
3030

3131
Let's take a look at an example and run through the algorithm to see how it works. Given is the array:
3232

@@ -38,7 +38,7 @@ Let's find out if there exist two entries whose sum is equal to 10.
3838

3939
Initially, our dictionary is empty. We begin looping through each element:
4040

41-
- **i = 0**: Is `7` in the dictionary? No. We add the difference between the target `k` and the current number to the dictionary. The difference is `10 - 7 = 3`, so the dictionary key is `3`. The value for that key is the current index, `0`. The dictionary now looks like this:
41+
- **i = 0**: Is `7` in the dictionary? No. We add the difference between the `target` and the current number to the dictionary. The difference is `10 - 7 = 3`, so the dictionary key is `3`. The value for that key is the current index, `0`. The dictionary now looks like this:
4242

4343
```swift
4444
[ 3: 0 ]

0 commit comments

Comments
 (0)