Skip to content

Commit fac4075

Browse files
committed
feat: add new lc problems
1 parent cc645a0 commit fac4075

File tree

29 files changed

+772
-36
lines changed

29 files changed

+772
-36
lines changed

solution/0300-0399/0336.Palindrome Pairs/README_EN.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,41 @@
44

55
## Description
66

7-
<p>Given a list of <b>unique</b> words, return all the pairs of the&nbsp;<b><i>distinct</i></b> indices <code>(i, j)</code> in the given list, so that the concatenation of the two words&nbsp;<code>words[i] + words[j]</code> is a palindrome.</p>
7+
<p>You are given a <strong>0-indexed</strong> array of <strong>unique</strong> strings <code>words</code>.</p>
8+
9+
<p>A <strong>palindrome pair</strong> is a pair of integers <code>(i, j)</code> such that:</p>
10+
11+
<ul>
12+
<li><code>0 &lt;= i, j &lt; word.length</code>,</li>
13+
<li><code>i != j</code>, and</li>
14+
<li><code>words[i] + words[j]</code> (the concatenation of the two strings) is a palindrome string.</li>
15+
</ul>
16+
17+
<p>Return <em>an array of all the <strong>palindrome pairs</strong> of </em><code>words</code>.</p>
818

919
<p>&nbsp;</p>
10-
<p><strong>Example 1:</strong></p>
20+
<p><strong class="example">Example 1:</strong></p>
1121

1222
<pre>
1323
<strong>Input:</strong> words = [&quot;abcd&quot;,&quot;dcba&quot;,&quot;lls&quot;,&quot;s&quot;,&quot;sssll&quot;]
1424
<strong>Output:</strong> [[0,1],[1,0],[3,2],[2,4]]
15-
<strong>Explanation:</strong> The palindromes are [&quot;dcbaabcd&quot;,&quot;abcddcba&quot;,&quot;slls&quot;,&quot;llssssll&quot;]
25+
<strong>Explanation:</strong> The palindromes are [&quot;abcddcba&quot;,&quot;dcbaabcd&quot;,&quot;slls&quot;,&quot;llssssll&quot;]
1626
</pre>
1727

18-
<p><strong>Example 2:</strong></p>
28+
<p><strong class="example">Example 2:</strong></p>
1929

2030
<pre>
2131
<strong>Input:</strong> words = [&quot;bat&quot;,&quot;tab&quot;,&quot;cat&quot;]
2232
<strong>Output:</strong> [[0,1],[1,0]]
2333
<strong>Explanation:</strong> The palindromes are [&quot;battab&quot;,&quot;tabbat&quot;]
2434
</pre>
2535

26-
<p><strong>Example 3:</strong></p>
36+
<p><strong class="example">Example 3:</strong></p>
2737

2838
<pre>
2939
<strong>Input:</strong> words = [&quot;a&quot;,&quot;&quot;]
3040
<strong>Output:</strong> [[0,1],[1,0]]
41+
<strong>Explanation:</strong> The palindromes are [&quot;a&quot;,&quot;a&quot;]
3142
</pre>
3243

3344
<p>&nbsp;</p>
@@ -36,7 +47,7 @@
3647
<ul>
3748
<li><code>1 &lt;= words.length &lt;= 5000</code></li>
3849
<li><code>0 &lt;= words[i].length &lt;= 300</code></li>
39-
<li><code>words[i]</code> consists of lower-case English letters.</li>
50+
<li><code>words[i]</code> consists of lowercase English letters.</li>
4051
</ul>
4152

4253
## Solutions

solution/0300-0399/0348.Design Tic-Tac-Toe/README_EN.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
<li>A player who succeeds in placing <code>n</code> of their marks in a horizontal, vertical, or diagonal row wins the game.</li>
1313
</ol>
1414

15-
<p>Implement the&nbsp;<code>TicTacToe</code> class:</p>
15+
<p>Implement the <code>TicTacToe</code> class:</p>
1616

1717
<ul>
1818
<li><code>TicTacToe(int n)</code> Initializes the object the size of the board <code>n</code>.</li>
19-
<li><code>int move(int row, int col, int player)</code> Indicates that the player with id <code>player</code> plays at the cell <code>(row, col)</code> of the board. The move is guaranteed to be a valid move.</li>
19+
<li><code>int move(int row, int col, int player)</code> Indicates that the player with id <code>player</code> plays at the cell <code>(row, col)</code> of the board. The move is guaranteed to be a valid move, and the two players alternate in making moves. Return
20+
<ul>
21+
<li><code>0</code> if there is <strong>no winner</strong> after the move,</li>
22+
<li><code>1</code> if <strong>player 1</strong> is the winner after the move, or</li>
23+
<li><code>2</code> if <strong>player 2</strong> is the winner after the move.</li>
24+
</ul>
25+
</li>
2026
</ul>
2127

2228
<p>&nbsp;</p>

solution/0400-0499/0493.Reverse Pairs/README_EN.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
<p>Given an integer array <code>nums</code>, return <em>the number of <strong>reverse pairs</strong> in the array</em>.</p>
88

9-
<p>A reverse pair is a pair <code>(i, j)</code> where <code>0 &lt;= i &lt; j &lt; nums.length</code> and <code>nums[i] &gt; 2 * nums[j]</code>.</p>
9+
<p>A <strong>reverse pair</strong> is a pair <code>(i, j)</code> where:</p>
10+
11+
<ul>
12+
<li><code>0 &lt;= i &lt; j &lt; nums.length</code> and</li>
13+
<li><code>nums[i] &gt; 2 * nums[j]</code>.</li>
14+
</ul>
1015

1116
<p>&nbsp;</p>
1217
<p><strong>Example 1:</strong></p>
@@ -27,7 +32,7 @@
2732
<strong>Explanation:</strong> The reverse pairs are:
2833
(1, 4) --&gt; nums[1] = 4, nums[4] = 1, 4 &gt; 2 * 1
2934
(2, 4) --&gt; nums[2] = 3, nums[4] = 1, 3 &gt; 2 * 1
30-
(3, 4) --&gt; nums[3] = 3, nums[4] = 1, 5 &gt; 2 * 1
35+
(3, 4) --&gt; nums[3] = 5, nums[4] = 1, 5 &gt; 2 * 1
3136
</pre>
3237

3338
<p>&nbsp;</p>

solution/0700-0799/0718.Maximum Length of Repeated Subarray/README_EN.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
<p>Given two integer arrays <code>nums1</code> and <code>nums2</code>, return <em>the maximum length of a subarray that appears in <strong>both</strong> arrays</em>.</p>
88

99
<p>&nbsp;</p>
10-
<p><strong>Example 1:</strong></p>
10+
<p><strong class="example">Example 1:</strong></p>
1111

1212
<pre>
1313
<strong>Input:</strong> nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]
1414
<strong>Output:</strong> 3
1515
<strong>Explanation:</strong> The repeated subarray with maximum length is [3,2,1].
1616
</pre>
1717

18-
<p><strong>Example 2:</strong></p>
18+
<p><strong class="example">Example 2:</strong></p>
1919

2020
<pre>
2121
<strong>Input:</strong> nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0]
2222
<strong>Output:</strong> 5
23+
<strong>Explanation:</strong> The repeated subarray with maximum length is [0,0,0,0,0].
2324
</pre>
2425

2526
<p>&nbsp;</p>

solution/0700-0799/0775.Global and Local Inversions/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<strong>解释:</strong>有 2 个全局倒置,和 1 个局部倒置。
4343
</pre>
4444

45+
46+
4547
<p><strong>提示:</strong></p>
4648

4749
<ul>

solution/0800-0899/0854.K-Similar Strings/README_EN.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
<p>Given two anagrams <code>s1</code> and <code>s2</code>, return the smallest <code>k</code> for which <code>s1</code> and <code>s2</code> are <code>k</code><strong>-similar</strong>.</p>
1010

1111
<p>&nbsp;</p>
12-
<p><strong>Example 1:</strong></p>
12+
<p><strong class="example">Example 1:</strong></p>
1313

1414
<pre>
1515
<strong>Input:</strong> s1 = &quot;ab&quot;, s2 = &quot;ba&quot;
1616
<strong>Output:</strong> 1
17+
<strong>Explanation:</strong> The two string are 1-similar because we can use one swap to change s1 to s2: &quot;ab&quot; --&gt; &quot;ba&quot;.
1718
</pre>
1819

19-
<p><strong>Example 2:</strong></p>
20+
<p><strong class="example">Example 2:</strong></p>
2021

2122
<pre>
2223
<strong>Input:</strong> s1 = &quot;abc&quot;, s2 = &quot;bca&quot;
2324
<strong>Output:</strong> 2
25+
<strong>Explanation:</strong> The two strings are 2-similar because we can use two swaps to change s1 to s2: &quot;abc&quot; --&gt; &quot;bac&quot; --&gt; &quot;bca&quot;.
2426
</pre>
2527

2628
<p>&nbsp;</p>

solution/1000-1099/1012.Numbers With Repeated Digits/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Solution:
109109
class Solution:
110110
def numDupDigitsAtMostN(self, n: int) -> int:
111111
return n - self.f(n)
112-
112+
113113
def f(self, n):
114114
@cache
115115
def dfs(pos, mask, lead, limit):

solution/1000-1099/1012.Numbers With Repeated Digits/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Solution:
7777
class Solution:
7878
def numDupDigitsAtMostN(self, n: int) -> int:
7979
return n - self.f(n)
80-
80+
8181
def f(self, n):
8282
@cache
8383
def dfs(pos, mask, lead, limit):

solution/1700-1799/1770.Maximum Score from Performing Multiplication Operations/README_EN.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44

55
## Description
66

7-
<p>You are given two integer arrays <code>nums</code> and <code>multipliers</code><strong> </strong>of size <code>n</code> and <code>m</code> respectively, where <code>n &gt;= m</code>. The arrays are <strong>1-indexed</strong>.</p>
7+
<p>You are given two <strong>0-indexed</strong> integer arrays <code>nums</code> and <code>multipliers</code><strong> </strong>of size <code>n</code> and <code>m</code> respectively, where <code>n &gt;= m</code>.</p>
88

9-
<p>You begin with a score of <code>0</code>. You want to perform <strong>exactly</strong> <code>m</code> operations. On the <code>i<sup>th</sup></code> operation <strong>(1-indexed)</strong>, you will:</p>
9+
<p>You begin with a score of <code>0</code>. You want to perform <strong>exactly</strong> <code>m</code> operations. On the <code>i<sup>th</sup></code> operation (<strong>0-indexed</strong>) you will:</p>
1010

1111
<ul>
12-
<li>Choose one integer <code>x</code> from <strong>either the start or the end </strong>of the array <code>nums</code>.</li>
13-
<li>Add <code>multipliers[i] * x</code> to your score.</li>
14-
<li>Remove <code>x</code> from the array <code>nums</code>.</li>
12+
<li>Choose one integer <code>x</code> from <strong>either the start or the end </strong>of the array <code>nums</code>.</li>
13+
<li>Add <code>multipliers[i] * x</code> to your score.
14+
<ul>
15+
<li>Note that <code>multipliers[0]</code> corresponds to the first operation, <code>multipliers[1]</code> to the second operation, and so on.</li>
16+
</ul>
17+
</li>
18+
<li>Remove <code>x</code> from <code>nums</code>.</li>
1519
</ul>
1620

1721
<p>Return <em>the <strong>maximum</strong> score after performing </em><code>m</code> <em>operations.</em></p>
@@ -48,7 +52,7 @@ The total score is 50 + 15 - 9 + 4 + 42 = 102.
4852
<ul>
4953
<li><code>n == nums.length</code></li>
5054
<li><code>m == multipliers.length</code></li>
51-
<li><code>1 &lt;= m &lt;= 10<sup>3</sup></code></li>
55+
<li><code>1 &lt;= m &lt;= 300</code></li>
5256
<li><code>m &lt;= n &lt;= 10<sup>5</sup></code><code> </code></li>
5357
<li><code>-1000 &lt;= nums[i], multipliers[i] &lt;= 1000</code></li>
5458
</ul>

solution/2300-2399/2376.Count Special Integers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class Solution {
178178
class Solution {
179179
private int[] a = new int[11];
180180
private int[][] dp = new int[11][1 << 11];
181-
181+
182182
public int countSpecialNumbers(int n) {
183183
return f(n);
184184
}

0 commit comments

Comments
 (0)