-
Notifications
You must be signed in to change notification settings - Fork 93
Added description for tasks 4-7. #21
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
Added description for tasks 4-7.
- Loading branch information
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
src/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/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,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` |
34 changes: 34 additions & 0 deletions
src/main/java/g0001_0100/s0005_longest_palindromic_substring/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,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. |
39 changes: 39 additions & 0 deletions
src/main/java/g0001_0100/s0006_zigzag_conversion/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,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` |
35 changes: 35 additions & 0 deletions
src/main/java/g0001_0100/s0007_reverse_integer/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,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` |
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.