diff --git a/src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md b/src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md new file mode 100644 index 000000000..dbaf2e77c --- /dev/null +++ b/src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md @@ -0,0 +1,50 @@ +4\. Median of Two Sorted Arrays + +Hard + +Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. + +The overall run time complexity should be `O(log (m+n))`. + +**Example 1:** + +**Input:** nums1 = \[1,3\], nums2 = \[2\] + +**Output:** 2.00000 + +**Explanation:** merged array = \[1,2,3\] and median is 2. + +**Example 2:** + +**Input:** nums1 = \[1,2\], nums2 = \[3,4\] + +**Output:** 2.50000 + +**Explanation:** merged array = \[1,2,3,4\] and median is (2 + 3) / 2 = 2.5. + +**Example 3:** + +**Input:** nums1 = \[0,0\], nums2 = \[0,0\] + +**Output:** 0.00000 + +**Example 4:** + +**Input:** nums1 = \[\], nums2 = \[1\] + +**Output:** 1.00000 + +**Example 5:** + +**Input:** nums1 = \[2\], nums2 = \[\] + +**Output:** 2.00000 + +**Constraints:** + +* `nums1.length == m` +* `nums2.length == n` +* `0 <= m <= 1000` +* `0 <= n <= 1000` +* `1 <= m + n <= 2000` +* `-106 <= nums1[i], nums2[i] <= 106` \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md b/src/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md new file mode 100644 index 000000000..a481f2790 --- /dev/null +++ b/src/main/java/g0001_0100/s0005_longest_palindromic_substring/readme.md @@ -0,0 +1,34 @@ +5\. Longest Palindromic Substring + +Medium + +Given a string `s`, return _the longest palindromic substring_ in `s`. + +**Example 1:** + +**Input:** s = "babad" + +**Output:** "bab" **Note:** "aba" is also a valid answer. + +**Example 2:** + +**Input:** s = "cbbd" + +**Output:** "bb" + +**Example 3:** + +**Input:** s = "a" + +**Output:** "a" + +**Example 4:** + +**Input:** s = "ac" + +**Output:** "a" + +**Constraints:** + +* `1 <= s.length <= 1000` +* `s` consist of only digits and English letters. \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0006_zigzag_conversion/readme.md b/src/main/java/g0001_0100/s0006_zigzag_conversion/readme.md new file mode 100644 index 000000000..afa33c203 --- /dev/null +++ b/src/main/java/g0001_0100/s0006_zigzag_conversion/readme.md @@ -0,0 +1,39 @@ +6\. Zigzag Conversion + +Medium + +The string `"PAYPALISHIRING"` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) + +P A H N A P L S I I G Y I R + +And then read line by line: `"PAHNAPLSIIGYIR"` + +Write the code that will take a string and make this conversion given a number of rows: + +string convert(string s, int numRows); + +**Example 1:** + +**Input:** s = "PAYPALISHIRING", numRows = 3 + +**Output:** "PAHNAPLSIIGYIR" + +**Example 2:** + +**Input:** s = "PAYPALISHIRING", numRows = 4 + +**Output:** "PINALSIGYAHRPI" + +**Explanation:** P I N A L S I G Y A H R P I + +**Example 3:** + +**Input:** s = "A", numRows = 1 + +**Output:** "A" + +**Constraints:** + +* `1 <= s.length <= 1000` +* `s` consists of English letters (lower-case and upper-case), `','` and `'.'`. +* `1 <= numRows <= 1000` \ No newline at end of file diff --git a/src/main/java/g0001_0100/s0007_reverse_integer/readme.md b/src/main/java/g0001_0100/s0007_reverse_integer/readme.md new file mode 100644 index 000000000..9b53f169c --- /dev/null +++ b/src/main/java/g0001_0100/s0007_reverse_integer/readme.md @@ -0,0 +1,35 @@ +7\. Reverse Integer + +Medium + +Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. + +**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** + +**Example 1:** + +**Input:** x = 123 + +**Output:** 321 + +**Example 2:** + +**Input:** x = -123 + +**Output:** -321 + +**Example 3:** + +**Input:** x = 120 + +**Output:** 21 + +**Example 4:** + +**Input:** x = 0 + +**Output:** 0 + +**Constraints:** + +* `-231 <= x <= 231 - 1` \ No newline at end of file

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