Skip to content

Commit c0dc99b

Browse files
committed
feat: add solutions to lc problems: No.2441~2444
* No.2441.Largest Positive Integer That Exists With Its Negative * No.2442.Count Number of Distinct Integers After Reverse Operations * No.2443.Sum of Number and Its Reverse * No.2444.Count Subarrays With Fixed Bounds
1 parent 2c5797f commit c0dc99b

File tree

74 files changed

+2207
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2207
-142
lines changed

solution/0000-0099/0016.3Sum Closest/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<p><strong>Constraints:</strong></p>
3232

3333
<ul>
34-
<li><code>3 &lt;= nums.length &lt;= 1000</code></li>
34+
<li><code>3 &lt;= nums.length &lt;= 500</code></li>
3535
<li><code>-1000 &lt;= nums[i] &lt;= 1000</code></li>
3636
<li><code>-10<sup>4</sup> &lt;= target &lt;= 10<sup>4</sup></code></li>
3737
</ul>

solution/0000-0099/0039.Combination Sum/README_EN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p>The test cases are generated such that the number of unique combinations that sum up to <code>target</code> is less than <code>150</code> combinations for the given input.</p>
1212

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

1616
<pre>
1717
<strong>Input:</strong> candidates = [2,3,6,7], target = 7
@@ -22,14 +22,14 @@
2222
These are the only two combinations.
2323
</pre>
2424

25-
<p><strong class="example">Example 2:</strong></p>
25+
<p><strong>Example 2:</strong></p>
2626

2727
<pre>
2828
<strong>Input:</strong> candidates = [2,3,5], target = 8
2929
<strong>Output:</strong> [[2,2,2,2],[2,3,3],[3,5]]
3030
</pre>
3131

32-
<p><strong class="example">Example 3:</strong></p>
32+
<p><strong>Example 3:</strong></p>
3333

3434
<pre>
3535
<strong>Input:</strong> candidates = [2], target = 1
@@ -43,7 +43,7 @@ These are the only two combinations.
4343
<li><code>1 &lt;= candidates.length &lt;= 30</code></li>
4444
<li><code>2 &lt;= candidates[i] &lt;= 40</code></li>
4545
<li>All elements of <code>candidates</code> are <strong>distinct</strong>.</li>
46-
<li><code>1 &lt;= target &lt;= 500</code></li>
46+
<li><code>1 &lt;= target &lt;= 40</code></li>
4747
</ul>
4848

4949
## Solutions

solution/0100-0199/0192.Word Frequency/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<li>Words are separated by one or more whitespace characters.</li>
1515
</ul>
1616

17-
<p><strong>Example:</strong></p>
17+
<p><strong class="example">Example:</strong></p>
1818

1919
<p>Assume that <code>words.txt</code> has the following content:</p>
2020

solution/0200-0299/0236.Lowest Common Ancestor of a Binary Tree/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
<p>According to the <a href="https://en.wikipedia.org/wiki/Lowest_common_ancestor" target="_blank">definition of LCA on Wikipedia</a>: &ldquo;The lowest common ancestor is defined between two nodes <code>p</code> and <code>q</code> as the lowest node in <code>T</code> that has both <code>p</code> and <code>q</code> as descendants (where we allow <b>a node to be a descendant of itself</b>).&rdquo;</p>
1010

1111
<p>&nbsp;</p>
12-
<p><strong class="example">Example 1:</strong></p>
12+
<p><strong>Example 1:</strong></p>
1313
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0236.Lowest%20Common%20Ancestor%20of%20a%20Binary%20Tree/images/binarytree.png" style="width: 200px; height: 190px;" />
1414
<pre>
1515
<strong>Input:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
1616
<strong>Output:</strong> 3
1717
<strong>Explanation:</strong> The LCA of nodes 5 and 1 is 3.
1818
</pre>
1919

20-
<p><strong class="example">Example 2:</strong></p>
20+
<p><strong>Example 2:</strong></p>
2121
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0236.Lowest%20Common%20Ancestor%20of%20a%20Binary%20Tree/images/binarytree.png" style="width: 200px; height: 190px;" />
2222
<pre>
2323
<strong>Input:</strong> root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
2424
<strong>Output:</strong> 5
2525
<strong>Explanation:</strong> The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.
2626
</pre>
2727

28-
<p><strong class="example">Example 3:</strong></p>
28+
<p><strong>Example 3:</strong></p>
2929

3030
<pre>
3131
<strong>Input:</strong> root = [1,2], p = 1, q = 2

solution/0300-0399/0306.Additive Number/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<p><strong>Note:</strong> Numbers in the additive sequence <strong>cannot</strong> have leading zeros, so sequence <code>1, 2, 03</code> or <code>1, 02, 3</code> is invalid.</p>
1414

1515
<p>&nbsp;</p>
16-
<p><strong class="example">Example 1:</strong></p>
16+
<p><strong>Example 1:</strong></p>
1717

1818
<pre>
1919
<strong>Input:</strong> &quot;112358&quot;
@@ -23,7 +23,7 @@ The digits can form an additive sequence: 1, 1, 2, 3, 5, 8.
2323
1 + 1 = 2, 1 + 2 = 3, 2 + 3 = 5, 3 + 5 = 8
2424
</pre>
2525

26-
<p><strong class="example">Example 2:</strong></p>
26+
<p><strong>Example 2:</strong></p>
2727

2828
<pre>
2929
<strong>Input:</strong> &quot;199100199&quot;

solution/0300-0399/0320.Generalized Abbreviation/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
<p>Given a string <code>word</code>, return <em>a list of all the possible <strong>generalized abbreviations</strong> of</em> <code>word</code>. Return the answer in <strong>any order</strong>.</p>
2727

2828
<p>&nbsp;</p>
29-
<p><strong>Example 1:</strong></p>
29+
<p><strong class="example">Example 1:</strong></p>
3030
<pre><strong>Input:</strong> word = "word"
3131
<strong>Output:</strong> ["4","3d","2r1","2rd","1o2","1o1d","1or1","1ord","w3","w2d","w1r1","w1rd","wo2","wo1d","wor1","word"]
32-
</pre><p><strong>Example 2:</strong></p>
32+
</pre><p><strong class="example">Example 2:</strong></p>
3333
<pre><strong>Input:</strong> word = "a"
3434
<strong>Output:</strong> ["1","a"]
3535
</pre>

solution/0300-0399/0334.Increasing Triplet Subsequence/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
<p>Given an integer array <code>nums</code>, return <code>true</code><em> if there exists a triple of indices </em><code>(i, j, k)</code><em> such that </em><code>i &lt; j &lt; k</code><em> and </em><code>nums[i] &lt; nums[j] &lt; nums[k]</code>. If no such indices exists, return <code>false</code>.</p>
88

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

1212
<pre>
1313
<strong>Input:</strong> nums = [1,2,3,4,5]
1414
<strong>Output:</strong> true
1515
<strong>Explanation:</strong> Any triplet where i &lt; j &lt; k is valid.
1616
</pre>
1717

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

2020
<pre>
2121
<strong>Input:</strong> nums = [5,4,3,2,1]
2222
<strong>Output:</strong> false
2323
<strong>Explanation:</strong> No triplet exists.
2424
</pre>
2525

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

2828
<pre>
2929
<strong>Input:</strong> nums = [2,1,5,0,4,6]

solution/0600-0699/0679.24 Game/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
<p>Return <code>true</code> if you can get such expression that evaluates to <code>24</code>, and <code>false</code> otherwise.</p>
3030

3131
<p>&nbsp;</p>
32-
<p><strong>Example 1:</strong></p>
32+
<p><strong class="example">Example 1:</strong></p>
3333

3434
<pre>
3535
<strong>Input:</strong> cards = [4,1,8,7]
3636
<strong>Output:</strong> true
3737
<strong>Explanation:</strong> (8-4) * (7-1) = 24
3838
</pre>
3939

40-
<p><strong>Example 2:</strong></p>
40+
<p><strong class="example">Example 2:</strong></p>
4141

4242
<pre>
4343
<strong>Input:</strong> cards = [1,2,1,2]

solution/0600-0699/0682.Baseball Game/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<p>The test cases are generated such that the answer and all intermediate calculations fit in a <strong>32-bit</strong> integer and that all operations are valid.</p>
3737

3838
<p>&nbsp;</p>
39-
<p><strong>Example 1:</strong></p>
39+
<p><strong class="example">Example 1:</strong></p>
4040

4141
<pre>
4242
<strong>Input:</strong> ops = [&quot;5&quot;,&quot;2&quot;,&quot;C&quot;,&quot;D&quot;,&quot;+&quot;]
@@ -50,7 +50,7 @@
5050
The total sum is 5 + 10 + 15 = 30.
5151
</pre>
5252

53-
<p><strong>Example 2:</strong></p>
53+
<p><strong class="example">Example 2:</strong></p>
5454

5555
<pre>
5656
<strong>Input:</strong> ops = [&quot;5&quot;,&quot;-2&quot;,&quot;4&quot;,&quot;C&quot;,&quot;D&quot;,&quot;9&quot;,&quot;+&quot;,&quot;+&quot;]
@@ -67,7 +67,7 @@ The total sum is 5 + 10 + 15 = 30.
6767
The total sum is 5 + -2 + -4 + 9 + 5 + 14 = 27.
6868
</pre>
6969

70-
<p><strong>Example 3:</strong></p>
70+
<p><strong class="example">Example 3:</strong></p>
7171

7272
<pre>
7373
<strong>Input:</strong> ops = [&quot;1&quot;,&quot;C&quot;]

solution/0700-0799/0724.Find Pivot Index/README_EN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
<p>If the index is on the left edge of the array, then the left sum is <code>0</code> because there are no elements to the left. This also applies to the right edge of the array.</p>
1212

13-
<p>Return <em>the <strong>leftmost pivot index</strong></em>. If no such index exists, return -1.</p>
13+
<p>Return <em>the <strong>leftmost pivot index</strong></em>. If no such index exists, return <code>-1</code>.</p>
1414

1515
<p>&nbsp;</p>
16-
<p><strong class="example">Example 1:</strong></p>
16+
<p><strong>Example 1:</strong></p>
1717

1818
<pre>
1919
<strong>Input:</strong> nums = [1,7,3,6,5,6]
@@ -24,15 +24,15 @@ Left sum = nums[0] + nums[1] + nums[2] = 1 + 7 + 3 = 11
2424
Right sum = nums[4] + nums[5] = 5 + 6 = 11
2525
</pre>
2626

27-
<p><strong class="example">Example 2:</strong></p>
27+
<p><strong>Example 2:</strong></p>
2828

2929
<pre>
3030
<strong>Input:</strong> nums = [1,2,3]
3131
<strong>Output:</strong> -1
3232
<strong>Explanation:</strong>
3333
There is no index that satisfies the conditions in the problem statement.</pre>
3434

35-
<p><strong class="example">Example 3:</strong></p>
35+
<p><strong>Example 3:</strong></p>
3636

3737
<pre>
3838
<strong>Input:</strong> nums = [2,1,-1]

0 commit comments

Comments
 (0)