diff --git a/src/main/java/g0001_0100/s0014_longest_common_prefix/readme.md b/src/main/java/g0001_0100/s0014_longest_common_prefix/readme.md new file mode 100644 index 000000000..0d48ab86f --- /dev/null +++ b/src/main/java/g0001_0100/s0014_longest_common_prefix/readme.md @@ -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. \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0015_three_sum/readme.md b/src/main/java/g0001_0100/s0015_three_sum/readme.md new file mode 100644 index 000000000..abc29262f --- /dev/null +++ b/src/main/java/g0001_0100/s0015_three_sum/readme.md @@ -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` \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0016_three_sum_closest/readme.md b/src/main/java/g0001_0100/s0016_three_sum_closest/readme.md new file mode 100644 index 000000000..823d367dc --- /dev/null +++ b/src/main/java/g0001_0100/s0016_three_sum_closest/readme.md @@ -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` \ No newline at end of file