Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/java/g0001_0100/s0014_longest_common_prefix/readme.md
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
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
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`