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/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/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>
<h2><ahref="https://leetcode.com/problems/container-with-most-water/">11. Container With Most Water</a></h2><h3>Medium</h3><hr><div><p>You are given an integer array <code>height</code> of length <code>n</code>. There are <code>n</code> vertical lines drawn such that the two endpoints of the <code>i<sup>th</sup></code> line are <code>(i, 0)</code> and <code>(i, height[i])</code>.</p>
2
+
3
+
<p>Find two lines that together with the x-axis form a container, such that the container contains the most water.</p>
4
+
5
+
<p>Return <em>the maximum amount of water a container can store</em>.</p>
6
+
7
+
<p><strong>Notice</strong> that you may not slant the container.</p>
<strong>Explanation:</strong> The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
15
+
</pre>
16
+
17
+
<p><strongclass="example">Example 2:</strong></p>
18
+
19
+
<pre><strong>Input:</strong> height = [1,1]
20
+
<strong>Output:</strong> 1
21
+
</pre>
22
+
23
+
<p> </p>
24
+
<p><strong>Constraints:</strong></p>
25
+
26
+
<ul>
27
+
<li><code>n == height.length</code></li>
28
+
<li><code>2 <= n <= 10<sup>5</sup></code></li>
<h2><ahref="https://leetcode.com/problems/integer-to-roman/">12. Integer to Roman</a></h2><h3>Medium</h3><hr><div><p>Roman numerals are represented by seven different symbols: <code>I</code>, <code>V</code>, <code>X</code>, <code>L</code>, <code>C</code>, <code>D</code> and <code>M</code>.</p>
<p>For example, <code>2</code> is written as <code>II</code> in Roman numeral, just two one's added together. <code>12</code> is written as <code>XII</code>, which is simply <code>X + II</code>. The number <code>27</code> is written as <code>XXVII</code>, which is <code>XX + V + II</code>.</p>
13
+
14
+
<p>Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not <code>IIII</code>. Instead, the number four is written as <code>IV</code>. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as <code>IX</code>. There are six instances where subtraction is used:</p>
15
+
16
+
<ul>
17
+
<li><code>I</code> can be placed before <code>V</code> (5) and <code>X</code> (10) to make 4 and 9. </li>
18
+
<li><code>X</code> can be placed before <code>L</code> (50) and <code>C</code> (100) to make 40 and 90. </li>
19
+
<li><code>C</code> can be placed before <code>D</code> (500) and <code>M</code> (1000) to make 400 and 900.</li>
20
+
</ul>
21
+
22
+
<p>Given an integer, convert it to a roman numeral.</p>
23
+
24
+
<p> </p>
25
+
<p><strongclass="example">Example 1:</strong></p>
26
+
27
+
<pre><strong>Input:</strong> num = 3
28
+
<strong>Output:</strong> "III"
29
+
<strong>Explanation:</strong> 3 is represented as 3 ones.
30
+
</pre>
31
+
32
+
<p><strongclass="example">Example 2:</strong></p>
33
+
34
+
<pre><strong>Input:</strong> num = 58
35
+
<strong>Output:</strong> "LVIII"
36
+
<strong>Explanation:</strong> L = 50, V = 5, III = 3.
37
+
</pre>
38
+
39
+
<p><strongclass="example">Example 3:</strong></p>
40
+
41
+
<pre><strong>Input:</strong> num = 1994
42
+
<strong>Output:</strong> "MCMXCIV"
43
+
<strong>Explanation:</strong> M = 1000, CM = 900, XC = 90 and IV = 4.
<h2><ahref="https://leetcode.com/problems/3sum/">15. 3Sum</a></h2><h3>Medium</h3><hr><div><p>Given an integer array nums, return all the triplets <code>[nums[i], nums[j], nums[k]]</code> such that <code>i != j</code>, <code>i != k</code>, and <code>j != k</code>, and <code>nums[i] + nums[j] + nums[k] == 0</code>.</p>
2
+
3
+
<p>Notice that the solution set must not contain duplicate triplets.</p>
0 commit comments