Update README.md
Browse files
README.md
CHANGED
@@ -25,6 +25,23 @@ Here is a recipe for Mai Tai:\n\n1:
|
|
25 |
> 3 parts rum, 2: 3 parts pineapple juice, 3: half a cup of lime juice, 4: 6 to 8 fresh or frozen pineapple chunks, 5: crushed ice.
|
26 |
> Mix all ingredients except ice and pour into glasses with ice. Garnish with a pineapple slice.
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
## Merge Details
|
29 |
### Merge Method
|
30 |
|
|
|
25 |
> 3 parts rum, 2: 3 parts pineapple juice, 3: half a cup of lime juice, 4: 6 to 8 fresh or frozen pineapple chunks, 5: crushed ice.
|
26 |
> Mix all ingredients except ice and pour into glasses with ice. Garnish with a pineapple slice.
|
27 |
|
28 |
+
Here is an implementation of 2-sum in golang:\n\n```go
|
29 |
+
> func twoSum(nums []int, target int) []int {
|
30 |
+
> if len(nums) <= 1 { return nil }
|
31 |
+
> m := map[int] bool{}
|
32 |
+
> for i := range(nums) {{
|
33 |
+
> n = nums[i]\n\n // find the complement of current number in map
|
34 |
+
> comp = target - n
|
35 |
+
> if comp in m { return [m[comp], i+1 ] }
|
36 |
+
> else { m[n] = true }
|
37 |
+
> }}
|
38 |
+
> return nil
|
39 |
+
> }
|
40 |
+
> ```
|
41 |
+
|
42 |
+
|
43 |
+
# Output should be [2,3] because that' is the position of where 4+4 =8 exists in our list
|
44 |
+
|
45 |
## Merge Details
|
46 |
### Merge Method
|
47 |
|