You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/1-1000/15-3sum.md
+21-18Lines changed: 21 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,17 +36,17 @@ Notice that the order of the output and the order of the triplets does not matte
36
36
37
37
### [Constraints]
38
38
-`3 <= nums.length <= 3000`
39
-
-`-10**5 <= nums[i] <= 10**5`
39
+
-`-10^5 <= nums[i] <= 10^5`
40
40
41
41
### [Hints]
42
42
<details>
43
43
<summary>Hint 1</summary>
44
-
So, we essentially need to find three numbers x, y, and z such that they add up to the given value. If we fix one of the numbers say x, we are left with the two-sum problem at hand!
44
+
So, we essentially need to find three numbers `x`, `y`, and `z` such that they add up to the given value. If we fix one of the numbers say `x`, we are left with the two-sum problem at hand!
45
45
</details>
46
46
47
47
<details>
48
48
<summary>Hint 2</summary>
49
-
For the two-sum problem, if we fix one of the numbers, say x, we have to scan the entire array to find the next number y, which is value - x where value is the input parameter. Can we change our array somehow so that this search becomes faster?
49
+
For the two-sum problem, if we fix one of the numbers, say `x`, we have to scan the entire array to find the next number `y`, which is `value - x` where value is the input parameter. Can we change our array somehow so that this search becomes faster?
50
50
</details>
51
51
52
52
<details>
@@ -55,7 +55,7 @@ Notice that the order of the output and the order of the triplets does not matte
55
55
</details>
56
56
57
57
## Intuition
58
-
1. The `sum` of three numbers equals `0`, which is equivalent to the `sum` of _two numbers_ equaling the _**negative** third number_.
58
+
1. The `sum` of three numbers equals `0`, which is equivalent to the `sum` of *two numbers* equaling the ***negative** third number*.
59
59
2. There are two options:
60
60
1. First `determine two numbers` and `find the third number`
61
61
2. First `determine one number` and `find the other two numbers`
@@ -64,30 +64,33 @@ Notice that the order of the output and the order of the triplets does not matte
64
64
5. For `option 1`, only the `Python` sample code is given. This article focuses on `option 2`.
0 commit comments