Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3476984

Browse files
authored
Added descriptions 14-16.
1 parent 0f258bc commit 3476984

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
14\. Longest Common Prefix
2+
3+
Easy
4+
5+
Write a function to find the longest common prefix string amongst an array of strings.
6+
7+
If there is no common prefix, return an empty string `""`.
8+
9+
**Example 1:**
10+
11+
**Input:** strs = \["flower","flow","flight"\]
12+
13+
**Output:** "fl"
14+
15+
**Example 2:**
16+
17+
**Input:** strs = \["dog","racecar","car"\]
18+
19+
**Output:** ""
20+
21+
**Explanation:** There is no common prefix among the input strings.
22+
23+
**Constraints:**
24+
25+
* `1 <= strs.length <= 200`
26+
* `0 <= strs[i].length <= 200`
27+
* `strs[i]` consists of only lower-case English letters.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
15\. 3Sum
2+
3+
Medium
4+
5+
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`.
6+
7+
Notice that the solution set must not contain duplicate triplets.
8+
9+
**Example 1:**
10+
11+
**Input:** nums = \[-1,0,1,2,-1,-4\]
12+
13+
**Output:** \[\[-1,-1,2\],\[-1,0,1\]\]
14+
15+
**Example 2:**
16+
17+
**Input:** nums = \[\]
18+
19+
**Output:** \[\]
20+
21+
**Example 3:**
22+
23+
**Input:** nums = \[0\]
24+
25+
**Output:** \[\]
26+
27+
**Constraints:**
28+
29+
* `0 <= nums.length <= 3000`
30+
* `-105 <= nums[i] <= 105`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
16\. 3Sum Closest
2+
3+
Medium
4+
5+
Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`.
6+
7+
Return _the sum of the three integers_.
8+
9+
You may assume that each input would have exactly one solution.
10+
11+
**Example 1:**
12+
13+
**Input:** nums = \[-1,2,1,-4\], target = 1
14+
15+
**Output:** 2
16+
17+
**Explanation:** The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
18+
19+
**Example 2:**
20+
21+
**Input:** nums = \[0,0,0\], target = 1
22+
23+
**Output:** 0
24+
25+
**Constraints:**
26+
27+
* `3 <= nums.length <= 1000`
28+
* `-1000 <= nums[i] <= 1000`
29+
* `-104 <= target <= 104`

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /