-
Notifications
You must be signed in to change notification settings - Fork 97
Added descriptions 14-16. #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
src/main/java/g0001_0100/s0014_longest_common_prefix/readme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
14\. Longest Common Prefix | ||
|
||
Easy | ||
|
||
Write a function to find the longest common prefix string amongst an array of strings. | ||
|
||
If there is no common prefix, return an empty string `""`. | ||
|
||
**Example 1:** | ||
|
||
**Input:** strs = \["flower","flow","flight"\] | ||
|
||
**Output:** "fl" | ||
|
||
**Example 2:** | ||
|
||
**Input:** strs = \["dog","racecar","car"\] | ||
|
||
**Output:** "" | ||
|
||
**Explanation:** There is no common prefix among the input strings. | ||
|
||
**Constraints:** | ||
|
||
* `1 <= strs.length <= 200` | ||
* `0 <= strs[i].length <= 200` | ||
* `strs[i]` consists of only lower-case English letters. |
30 changes: 30 additions & 0 deletions
src/main/java/g0001_0100/s0015_three_sum/readme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
15\. 3Sum | ||
|
||
Medium | ||
|
||
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`. | ||
|
||
Notice that the solution set must not contain duplicate triplets. | ||
|
||
**Example 1:** | ||
|
||
**Input:** nums = \[-1,0,1,2,-1,-4\] | ||
|
||
**Output:** \[\[-1,-1,2\],\[-1,0,1\]\] | ||
|
||
**Example 2:** | ||
|
||
**Input:** nums = \[\] | ||
|
||
**Output:** \[\] | ||
|
||
**Example 3:** | ||
|
||
**Input:** nums = \[0\] | ||
|
||
**Output:** \[\] | ||
|
||
**Constraints:** | ||
|
||
* `0 <= nums.length <= 3000` | ||
* `-105 <= nums[i] <= 105` |
29 changes: 29 additions & 0 deletions
src/main/java/g0001_0100/s0016_three_sum_closest/readme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
16\. 3Sum Closest | ||
|
||
Medium | ||
|
||
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`. | ||
|
||
Return _the sum of the three integers_. | ||
|
||
You may assume that each input would have exactly one solution. | ||
|
||
**Example 1:** | ||
|
||
**Input:** nums = \[-1,2,1,-4\], target = 1 | ||
|
||
**Output:** 2 | ||
|
||
**Explanation:** The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). | ||
|
||
**Example 2:** | ||
|
||
**Input:** nums = \[0,0,0\], target = 1 | ||
|
||
**Output:** 0 | ||
|
||
**Constraints:** | ||
|
||
* `3 <= nums.length <= 1000` | ||
* `-1000 <= nums[i] <= 1000` | ||
* `-104 <= target <= 104` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.