Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bebc412

Browse files
authored
Added description for tasks 4-7.
1 parent f72b853 commit bebc412

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
4\. Median of Two Sorted Arrays
2+
3+
Hard
4+
5+
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays.
6+
7+
The overall run time complexity should be `O(log (m+n))`.
8+
9+
**Example 1:**
10+
11+
**Input:** nums1 = \[1,3\], nums2 = \[2\]
12+
13+
**Output:** 2.00000
14+
15+
**Explanation:** merged array = \[1,2,3\] and median is 2.
16+
17+
**Example 2:**
18+
19+
**Input:** nums1 = \[1,2\], nums2 = \[3,4\]
20+
21+
**Output:** 2.50000
22+
23+
**Explanation:** merged array = \[1,2,3,4\] and median is (2 + 3) / 2 = 2.5.
24+
25+
**Example 3:**
26+
27+
**Input:** nums1 = \[0,0\], nums2 = \[0,0\]
28+
29+
**Output:** 0.00000
30+
31+
**Example 4:**
32+
33+
**Input:** nums1 = \[\], nums2 = \[1\]
34+
35+
**Output:** 1.00000
36+
37+
**Example 5:**
38+
39+
**Input:** nums1 = \[2\], nums2 = \[\]
40+
41+
**Output:** 2.00000
42+
43+
**Constraints:**
44+
45+
* `nums1.length == m`
46+
* `nums2.length == n`
47+
* `0 <= m <= 1000`
48+
* `0 <= n <= 1000`
49+
* `1 <= m + n <= 2000`
50+
* `-106 <= nums1[i], nums2[i] <= 106`
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
5\. Longest Palindromic Substring
2+
3+
Medium
4+
5+
Given a string `s`, return _the longest palindromic substring_ in `s`.
6+
7+
**Example 1:**
8+
9+
**Input:** s = "babad"
10+
11+
**Output:** "bab" **Note:** "aba" is also a valid answer.
12+
13+
**Example 2:**
14+
15+
**Input:** s = "cbbd"
16+
17+
**Output:** "bb"
18+
19+
**Example 3:**
20+
21+
**Input:** s = "a"
22+
23+
**Output:** "a"
24+
25+
**Example 4:**
26+
27+
**Input:** s = "ac"
28+
29+
**Output:** "a"
30+
31+
**Constraints:**
32+
33+
* `1 <= s.length <= 1000`
34+
* `s` consist of only digits and English letters.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
6\. Zigzag Conversion
2+
3+
Medium
4+
5+
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)
6+
7+
P A H N A P L S I I G Y I R
8+
9+
And then read line by line: `"PAHNAPLSIIGYIR"`
10+
11+
Write the code that will take a string and make this conversion given a number of rows:
12+
13+
string convert(string s, int numRows);
14+
15+
**Example 1:**
16+
17+
**Input:** s = "PAYPALISHIRING", numRows = 3
18+
19+
**Output:** "PAHNAPLSIIGYIR"
20+
21+
**Example 2:**
22+
23+
**Input:** s = "PAYPALISHIRING", numRows = 4
24+
25+
**Output:** "PINALSIGYAHRPI"
26+
27+
**Explanation:** P I N A L S I G Y A H R P I
28+
29+
**Example 3:**
30+
31+
**Input:** s = "A", numRows = 1
32+
33+
**Output:** "A"
34+
35+
**Constraints:**
36+
37+
* `1 <= s.length <= 1000`
38+
* `s` consists of English letters (lower-case and upper-case), `','` and `'.'`.
39+
* `1 <= numRows <= 1000`
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
7\. Reverse Integer
2+
3+
Medium
4+
5+
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`.
6+
7+
**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
8+
9+
**Example 1:**
10+
11+
**Input:** x = 123
12+
13+
**Output:** 321
14+
15+
**Example 2:**
16+
17+
**Input:** x = -123
18+
19+
**Output:** -321
20+
21+
**Example 3:**
22+
23+
**Input:** x = 120
24+
25+
**Output:** 21
26+
27+
**Example 4:**
28+
29+
**Input:** x = 0
30+
31+
**Output:** 0
32+
33+
**Constraints:**
34+
35+
* `-231 <= x <= 231 - 1`

0 commit comments

Comments
(0)

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