Skip to content

Commit b8e514b

Browse files
committed
feat: add solutions to lc problem: No.1788
No.1788.Maximize the Beauty of the Garden
1 parent e24a164 commit b8e514b

File tree

50 files changed

+641
-198
lines changed

Some content is hidden

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

50 files changed

+641
-198
lines changed

solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
<p>Given a string <code>s</code>, find the length of the <strong>longest <span data-keyword="substring-nonempty">substring</span></strong> without repeating characters.</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> s = &quot;abcabcbb&quot;
1414
<strong>Output:</strong> 3
1515
<strong>Explanation:</strong> The answer is &quot;abc&quot;, with the length of 3.
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> s = &quot;bbbbb&quot;
2222
<strong>Output:</strong> 1
2323
<strong>Explanation:</strong> The answer is &quot;b&quot;, with the length of 1.
2424
</pre>
2525

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

2828
<pre>
2929
<strong>Input:</strong> s = &quot;pwwkew&quot;

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

Lines changed: 3 additions & 3 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>Example 1:</strong></p>
14+
<p><strong class="example">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>Example 2:</strong></p>
25+
<p><strong class="example">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>Example 3:</strong></p>
32+
<p><strong class="example">Example 3:</strong></p>
3333

3434
<pre>
3535
<strong>Input:</strong> candidates = [2], target = 1

solution/0000-0099/0063.Unique Paths II/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>You are given an <code>m x n</code> integer array <code>grid</code>. There is a robot initially located at the <b>top-left corner</b> (i.e., <code>grid[0][0]</code>). The robot tries to move to the <strong>bottom-right corner</strong> (i.e., <code>grid[m-1][n-1]</code>). The robot can only move either down or right at any point in time.</p>
7+
<p>You are given an <code>m x n</code> integer array <code>grid</code>. There is a robot initially located at the <b>top-left corner</b> (i.e., <code>grid[0][0]</code>). The robot tries to move to the <strong>bottom-right corner</strong> (i.e., <code>grid[m - 1][n - 1]</code>). The robot can only move either down or right at any point in time.</p>
88

99
<p>An obstacle and space are marked as <code>1</code> or <code>0</code> respectively in <code>grid</code>. A path that the robot takes cannot include <strong>any</strong> square that is an obstacle.</p>
1010

solution/0000-0099/0076.Minimum Window Substring/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Since the largest window of s only has one &#39;a&#39;, return empty string.
4242
<ul>
4343
<li><code>m == s.length</code></li>
4444
<li><code>n == t.length</code></li>
45-
<li><code>1 &lt;= m, n&nbsp;&lt;= 10<sup>5</sup></code></li>
45+
<li><code>1 &lt;= m, n &lt;= 10<sup>5</sup></code></li>
4646
<li><code>s</code> and <code>t</code> consist of uppercase and lowercase English letters.</li>
4747
</ul>
4848

solution/0100-0199/0140.Word Break II/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
<p><strong>Note</strong> that the same word in the dictionary may be reused multiple times in the segmentation.</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> s = &quot;catsanddog&quot;, wordDict = [&quot;cat&quot;,&quot;cats&quot;,&quot;and&quot;,&quot;sand&quot;,&quot;dog&quot;]
1616
<strong>Output:</strong> [&quot;cats and dog&quot;,&quot;cat sand dog&quot;]
1717
</pre>
1818

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

2121
<pre>
2222
<strong>Input:</strong> s = &quot;pineapplepenapple&quot;, wordDict = [&quot;apple&quot;,&quot;pen&quot;,&quot;applepen&quot;,&quot;pine&quot;,&quot;pineapple&quot;]
2323
<strong>Output:</strong> [&quot;pine apple pen apple&quot;,&quot;pineapple pen apple&quot;,&quot;pine applepen apple&quot;]
2424
<strong>Explanation:</strong> Note that you are allowed to reuse a dictionary word.
2525
</pre>
2626

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

2929
<pre>
3030
<strong>Input:</strong> s = &quot;catsandog&quot;, wordDict = [&quot;cats&quot;,&quot;dog&quot;,&quot;sand&quot;,&quot;and&quot;,&quot;cat&quot;]

solution/0100-0199/0162.Find Peak Element/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<p>You must write an algorithm that runs in <code>O(log n)</code> time.</p>
1414

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

1818
<pre>
1919
<strong>Input:</strong> nums = [1,2,3,1]
2020
<strong>Output:</strong> 2
2121
<strong>Explanation:</strong> 3 is a peak element and your function should return the index number 2.</pre>
2222

23-
<p><strong>Example 2:</strong></p>
23+
<p><strong class="example">Example 2:</strong></p>
2424

2525
<pre>
2626
<strong>Input:</strong> nums = [1,2,1,3,5,6,4]

solution/0200-0299/0219.Contains Duplicate II/README_EN.md

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

55
## Description
66

7-
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <code>true</code> if there are two <strong>distinct indices</strong> <code>i</code> and <code>j</code> in the array such that <code>nums[i] == nums[j]</code> and <code>abs(i - j) &lt;= k</code>.</p>
7+
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <code>true</code> <em>if there are two <strong>distinct indices</strong> </em><code>i</code><em> and </em><code>j</code><em> in the array such that </em><code>nums[i] == nums[j]</code><em> and </em><code>abs(i - j) &lt;= k</code>.</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> nums = [1,2,3,1], k = 3
1414
<strong>Output:</strong> true
1515
</pre>
1616

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

1919
<pre>
2020
<strong>Input:</strong> nums = [1,0,1,1], k = 1
2121
<strong>Output:</strong> true
2222
</pre>
2323

24-
<p><strong>Example 3:</strong></p>
24+
<p><strong class="example">Example 3:</strong></p>
2525

2626
<pre>
2727
<strong>Input:</strong> nums = [1,2,3,1,2,3], k = 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>Example 1:</strong></p>
16+
<p><strong class="example">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>Example 2:</strong></p>
26+
<p><strong class="example">Example 2:</strong></p>
2727

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

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>Example 1:</strong></p>
10+
<p><strong class="example">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>Example 2:</strong></p>
18+
<p><strong class="example">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>Example 3:</strong></p>
26+
<p><strong class="example">Example 3:</strong></p>
2727

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

solution/0400-0499/0411.Minimum Unique Word Abbreviation/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<p>Given a target string <code>target</code> and an array of strings <code>dictionary</code>, return <em>an <strong>abbreviation</strong> of </em><code>target</code><em> with the <strong>shortest possible length</strong> such that it is <strong>not an abbreviation</strong> of <strong>any</strong> string in </em><code>dictionary</code><em>. If there are multiple shortest abbreviations, return any of them</em>.</p>
2222

2323
<p>&nbsp;</p>
24-
<p><strong>Example 1:</strong></p>
24+
<p><strong class="example">Example 1:</strong></p>
2525

2626
<pre>
2727
<strong>Input:</strong> target = &quot;apple&quot;, dictionary = [&quot;blade&quot;]
@@ -31,7 +31,7 @@ The next shortest abbreviations are &quot;a4&quot; and &quot;4e&quot;. &quot;4e&
3131
Hence, return &quot;a4&quot;.
3232
</pre>
3333

34-
<p><strong>Example 2:</strong></p>
34+
<p><strong class="example">Example 2:</strong></p>
3535

3636
<pre>
3737
<strong>Input:</strong> target = &quot;apple&quot;, dictionary = [&quot;blade&quot;,&quot;plain&quot;,&quot;amber&quot;]

0 commit comments

Comments
 (0)