Skip to content

Commit 69433d3

Browse files
committed
test README
1 parent bb82fd0 commit 69433d3

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

typescript/problem_0015/3Sum.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
/*
2-
* [15] 3Sum
3-
*
4-
* Difficulty: TODO
5-
*/
6-
7-
const threeSum = (nums: number[]) => {
1+
export const threeSum = (nums: number[]) => {
82
const result = [];
93

104
nums.sort((a, b) => a - b);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {test, expect} from 'vitest';
2+
import {threeSum} from './3Sum.ts';
3+
4+
test('threeSum', () => {
5+
// TODO: Add test cases
6+
expect(1).toBe(1);
7+
});

typescript/problem_0015/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# [15] 3Sum
2+
3+
**Difficulty:** Medium
4+
5+
## Problem Description
6+
7+
Given an integer array nums, return all the triplets `[nums[i], nums[j], nums[k]]` such that `i != j`, `i != k`, and `j != k`, and `nums[i] + nums[j] + nums[k] == 0`.
8+
9+
Notice that the solution set must not contain duplicate triplets.
10+
11+
**Example 1:**
12+
13+
**Input:** nums = \[-1,0,1,2,-1,-4\]
14+
**Output:** \[\[-1,-1,2\],\[-1,0,1\]\]
15+
**Explanation:**
16+
nums\[0\] + nums\[1\] + nums\[2\] = (-1) + 0 + 1 = 0.
17+
nums\[1\] + nums\[2\] + nums\[4\] = 0 + 1 + (-1) = 0.
18+
nums\[0\] + nums\[3\] + nums\[4\] = (-1) + 2 + (-1) = 0.
19+
The distinct triplets are \[-1,0,1\] and \[-1,-1,2\].
20+
Notice that the order of the output and the order of the triplets does not matter.
21+
22+
**Example 2:**
23+
24+
**Input:** nums = \[0,1,1\]
25+
**Output:** \[\]
26+
**Explanation:** The only possible triplet does not sum up to 0.
27+
28+
**Example 3:**
29+
30+
**Input:** nums = \[0,0,0\]
31+
**Output:** \[\[0,0,0\]\]
32+
**Explanation:** The only possible triplet sums up to 0.
33+
34+
**Constraints:**
35+
36+
* `3 <= nums.length <= 3000`
37+
* `-105 <= nums[i] <= 105`

0 commit comments

Comments
 (0)