You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2><ahref="https://leetcode.com/problems/two-sum/">1. Two Sum</a></h2><h3>Easy</h3><hr><div><p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>
2
+
3
+
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> element twice.</p>
<h2><ahref="https://leetcode.com/problems/add-two-numbers/">2. Add Two Numbers</a></h2><h3>Medium</h3><hr><div><p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.</p>
2
+
3
+
<p>You may assume the two numbers do not contain any leading zero, except the number 0 itself.</p>
<h2><ahref="https://leetcode.com/problems/longest-substring-without-repeating-characters/">3. Longest Substring Without Repeating Characters</a></h2><h3>Medium</h3><hr><div><p>Given a string <code>s</code>, find the length of the <strong>longest</strong><spandata-keyword="substring-nonempty"><strong>substring</strong></span> without repeating characters.</p>
2
+
3
+
<p> </p>
4
+
<p><strongclass="example">Example 1:</strong></p>
5
+
6
+
<pre><strong>Input:</strong> s = "abcabcbb"
7
+
<strong>Output:</strong> 3
8
+
<strong>Explanation:</strong> The answer is "abc", with the length of 3.
9
+
</pre>
10
+
11
+
<p><strongclass="example">Example 2:</strong></p>
12
+
13
+
<pre><strong>Input:</strong> s = "bbbbb"
14
+
<strong>Output:</strong> 1
15
+
<strong>Explanation:</strong> The answer is "b", with the length of 1.
16
+
</pre>
17
+
18
+
<p><strongclass="example">Example 3:</strong></p>
19
+
20
+
<pre><strong>Input:</strong> s = "pwwkew"
21
+
<strong>Output:</strong> 3
22
+
<strong>Explanation:</strong> The answer is "wke", with the length of 3.
23
+
Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
<h2><ahref="https://leetcode.com/problems/median-of-two-sorted-arrays/">4. Median of Two Sorted Arrays</a></h2><h3>Hard</h3><hr><div><p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>
2
+
3
+
<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>
<h2><ahref="https://leetcode.com/problems/zigzag-conversion/">6. Zigzag Conversion</a></h2><h3>Medium</h3><hr><div><p>The string <code>"PAYPALISHIRING"</code> 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>
2
+
3
+
<pre>P A H N
4
+
A P L S I I G
5
+
Y I R
6
+
</pre>
7
+
8
+
<p>And then read line by line: <code>"PAHNAPLSIIGYIR"</code></p>
9
+
10
+
<p>Write the code that will take a string and make this conversion given a number of rows:</p>
11
+
12
+
<pre>string convert(string s, int numRows);
13
+
</pre>
14
+
15
+
<p> </p>
16
+
<p><strongclass="example">Example 1:</strong></p>
17
+
18
+
<pre><strong>Input:</strong> s = "PAYPALISHIRING", numRows = 3
19
+
<strong>Output:</strong> "PAHNAPLSIIGYIR"
20
+
</pre>
21
+
22
+
<p><strongclass="example">Example 2:</strong></p>
23
+
24
+
<pre><strong>Input:</strong> s = "PAYPALISHIRING", numRows = 4
25
+
<strong>Output:</strong> "PINALSIGYAHRPI"
26
+
<strong>Explanation:</strong>
27
+
P I N
28
+
A L S I G
29
+
Y A H R
30
+
P I
31
+
</pre>
32
+
33
+
<p><strongclass="example">Example 3:</strong></p>
34
+
35
+
<pre><strong>Input:</strong> s = "A", numRows = 1
36
+
<strong>Output:</strong> "A"
37
+
</pre>
38
+
39
+
<p> </p>
40
+
<p><strong>Constraints:</strong></p>
41
+
42
+
<ul>
43
+
<li><code>1 <= s.length <= 1000</code></li>
44
+
<li><code>s</code> consists of English letters (lower-case and upper-case), <code>','</code> and <code>'.'</code>.</li>
<h2><ahref="https://leetcode.com/problems/reverse-integer/">7. Reverse Integer</a></h2><h3>Medium</h3><hr><div><p>Given a signed 32-bit integer <code>x</code>, return <code>x</code><em> with its digits reversed</em>. If reversing <code>x</code> causes the value to go outside the signed 32-bit integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then return <code>0</code>.</p>
2
+
3
+
<p><strong>Assume the environment does not allow you to store 64-bit integers (signed or unsigned).</strong></p>
4
+
5
+
<p> </p>
6
+
<p><strongclass="example">Example 1:</strong></p>
7
+
8
+
<pre><strong>Input:</strong> x = 123
9
+
<strong>Output:</strong> 321
10
+
</pre>
11
+
12
+
<p><strongclass="example">Example 2:</strong></p>
13
+
14
+
<pre><strong>Input:</strong> x = -123
15
+
<strong>Output:</strong> -321
16
+
</pre>
17
+
18
+
<p><strongclass="example">Example 3:</strong></p>
19
+
20
+
<pre><strong>Input:</strong> x = 120
21
+
<strong>Output:</strong> 21
22
+
</pre>
23
+
24
+
<p> </p>
25
+
<p><strong>Constraints:</strong></p>
26
+
27
+
<ul>
28
+
<li><code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code></li>
<h2><ahref="https://leetcode.com/problems/string-to-integer-atoi/">8. String to Integer (atoi)</a></h2><h3>Medium</h3><hr><div><p>Implement the <code>myAtoi(string s)</code> function, which converts a string to a 32-bit signed integer (similar to C/C++'s <code>atoi</code> function).</p>
2
+
3
+
<p>The algorithm for <code>myAtoi(string s)</code> is as follows:</p>
4
+
5
+
<ol>
6
+
<li>Read in and ignore any leading whitespace.</li>
7
+
<li>Check if the next character (if not already at the end of the string) is <code>'-'</code> or <code>'+'</code>. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.</li>
8
+
<li>Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.</li>
9
+
<li>Convert these digits into an integer (i.e. <code>"123" -> 123</code>, <code>"0032" -> 32</code>). If no digits were read, then the integer is <code>0</code>. Change the sign as necessary (from step 2).</li>
10
+
<li>If the integer is out of the 32-bit signed integer range <code>[-2<sup>31</sup>, 2<sup>31</sup> - 1]</code>, then clamp the integer so that it remains in the range. Specifically, integers less than <code>-2<sup>31</sup></code> should be clamped to <code>-2<sup>31</sup></code>, and integers greater than <code>2<sup>31</sup> - 1</code> should be clamped to <code>2<sup>31</sup> - 1</code>.</li>
11
+
<li>Return the integer as the final result.</li>
12
+
</ol>
13
+
14
+
<p><strong>Note:</strong></p>
15
+
16
+
<ul>
17
+
<li>Only the space character <code>' '</code> is considered a whitespace character.</li>
18
+
<li><strong>Do not ignore</strong> any characters other than the leading whitespace or the rest of the string after the digits.</li>
19
+
</ul>
20
+
21
+
<p> </p>
22
+
<p><strongclass="example">Example 1:</strong></p>
23
+
24
+
<pre><strong>Input:</strong> s = "42"
25
+
<strong>Output:</strong> 42
26
+
<strong>Explanation:</strong> The underlined characters are what is read in, the caret is the current reader position.
27
+
Step 1: "42" (no characters read because there is no leading whitespace)
28
+
^
29
+
Step 2: "42" (no characters read because there is neither a '-' nor '+')
30
+
^
31
+
Step 3: "<u>42</u>" ("42" is read in)
32
+
^
33
+
The parsed integer is 42.
34
+
Since 42 is in the range [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 42.
35
+
</pre>
36
+
37
+
<p><strongclass="example">Example 2:</strong></p>
38
+
39
+
<pre><strong>Input:</strong> s = " -42"
40
+
<strong>Output:</strong> -42
41
+
<strong>Explanation:</strong>
42
+
Step 1: "<u></u>-42" (leading whitespace is read and ignored)
43
+
^
44
+
Step 2: " <u>-</u>42" ('-' is read, so the result should be negative)
45
+
^
46
+
Step 3: " -<u>42</u>" ("42" is read in)
47
+
^
48
+
The parsed integer is -42.
49
+
Since -42 is in the range [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is -42.
50
+
</pre>
51
+
52
+
<p><strongclass="example">Example 3:</strong></p>
53
+
54
+
<pre><strong>Input:</strong> s = "4193 with words"
55
+
<strong>Output:</strong> 4193
56
+
<strong>Explanation:</strong>
57
+
Step 1: "4193 with words" (no characters read because there is no leading whitespace)
58
+
^
59
+
Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+')
60
+
^
61
+
Step 3: "<u>4193</u> with words" ("4193" is read in; reading stops because the next character is a non-digit)
62
+
^
63
+
The parsed integer is 4193.
64
+
Since 4193 is in the range [-2<sup>31</sup>, 2<sup>31</sup> - 1], the final result is 4193.
65
+
</pre>
66
+
67
+
<p> </p>
68
+
<p><strong>Constraints:</strong></p>
69
+
70
+
<ul>
71
+
<li><code>0 <= s.length <= 200</code></li>
72
+
<li><code>s</code> consists of English letters (lower-case and upper-case), digits (<code>0-9</code>), <code>' '</code>, <code>'+'</code>, <code>'-'</code>, and <code>'.'</code>.</li>
0 commit comments