Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 40d392d

Browse files
author
Shuo
authored
Merge pull request #624 from openset/develop
Add: new
2 parents 58b3068 + 44e4aa9 commit 40d392d

File tree

32 files changed

+598
-21
lines changed

32 files changed

+598
-21
lines changed

‎README.md‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ LeetCode Problems' Solutions
5454

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1147">1147</span> | [Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition "段式回文") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-chunked-palindrome-decomposition) | Hard |
58+
| <span id="1146">1146</span> | [Snapshot Array](https://leetcode.com/problems/snapshot-array "快照数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/snapshot-array) | Medium |
59+
| <span id="1145">1145</span> | [Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game) | Medium |
60+
| <span id="1144">1144</span> | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag) | Medium |
61+
| <span id="1143">1143</span> | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence) | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence) | Medium |
62+
| <span id="1142">1142</span> | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-ii) | Easy |
63+
| <span id="1141">1141</span> | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-i) | Easy |
64+
| <span id="1140">1140</span> | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii) | Medium |
65+
| <span id="1139">1139</span> | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square) | Medium |
66+
| <span id="1138">1138</span> | [Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path "字母板上的路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path) | Medium |
67+
| <span id="1137">1137</span> | [N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number "第 N 个泰波那契数") | [Go](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number) | Easy |
5768
| <span id="1136">1136</span> | [Parallel Courses](https://leetcode.com/problems/parallel-courses "平行课程") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/parallel-courses) | Hard |
5869
| <span id="1135">1135</span> | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost "最低成本联通所有城市") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/connecting-cities-with-minimum-cost) | Medium |
5970
| <span id="1134">1134</span> | [Armstrong Number](https://leetcode.com/problems/armstrong-number "阿姆斯特朗数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/armstrong-number) | Easy |
@@ -73,7 +84,7 @@ LeetCode Problems' Solutions
7384
| <span id="1120">1120</span> | [Maximum Average Subtree](https://leetcode.com/problems/maximum-average-subtree "子树的最大平均值") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-average-subtree) | Medium |
7485
| <span id="1119">1119</span> | [Remove Vowels from a String](https://leetcode.com/problems/remove-vowels-from-a-string "删去字符串中的元音") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-vowels-from-a-string) | Easy |
7586
| <span id="1118">1118</span> | [Number of Days in a Month](https://leetcode.com/problems/number-of-days-in-a-month "一月有多少天") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-days-in-a-month) | Easy |
76-
| <span id="1117">1117</span> | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](https://github.com/openset/leetcode/tree/master/problems/building-h2o) | Hard |
87+
| <span id="1117">1117</span> | [Building H2O](https://leetcode.com/problems/building-h2o "H2O 生成") | [Go](https://github.com/openset/leetcode/tree/master/problems/building-h2o) | Medium |
7788
| <span id="1116">1116</span> | [Print Zero Even Odd](https://leetcode.com/problems/print-zero-even-odd "打印零与奇偶数") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-zero-even-odd) | Medium |
7889
| <span id="1115">1115</span> | [Print FooBar Alternately](https://leetcode.com/problems/print-foobar-alternately "交替打印FooBar") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-foobar-alternately) | Medium |
7990
| <span id="1114">1114</span> | [Print in Order](https://leetcode.com/problems/print-in-order "按序打印") | [Go](https://github.com/openset/leetcode/tree/master/problems/print-in-order) | Easy |
@@ -149,7 +160,7 @@ LeetCode Problems' Solutions
149160
| <span id="1044">1044</span> | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring) | Hard |
150161
| <span id="1043">1043</span> | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum) | Medium |
151162
| <span id="1042">1042</span> | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent) | Easy |
152-
| <span id="1041">1041</span> | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle) | Easy |
163+
| <span id="1041">1041</span> | [Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle "困于环中的机器人") | [Go](https://github.com/openset/leetcode/tree/master/problems/robot-bounded-in-circle) | Medium |
153164
| <span id="1040">1040</span> | [Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii "移动石子直到连续 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/moving-stones-until-consecutive-ii) | Medium |
154165
| <span id="1039">1039</span> | [Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon "多边形三角剖分的最低得分") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-score-triangulation-of-polygon) | Medium |
155166
| <span id="1038">1038</span> | [Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search-tree-to-greater-sum-tree) | Medium |
@@ -558,7 +569,7 @@ LeetCode Problems' Solutions
558569
| <span id="635">635</span> | [Design Log Storage System](https://leetcode.com/problems/design-log-storage-system "设计日志存储系统") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-log-storage-system) | Medium |
559570
| <span id="634">634</span> | [Find the Derangement of An Array](https://leetcode.com/problems/find-the-derangement-of-an-array "寻找数组的错位排列") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-the-derangement-of-an-array) | Medium |
560571
| <span id="633">633</span> | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers "平方数之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-square-numbers) | Easy |
561-
| <span id="632">632</span> | [Smallest Range](https://leetcode.com/problems/smallest-range "最小区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-range) | Hard |
572+
| <span id="632">632</span> | [Smallest Range Covering Elements from K Lists](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists "最小区间") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists) | Hard |
562573
| <span id="631">631</span> | [Design Excel Sum Formula](https://leetcode.com/problems/design-excel-sum-formula "设计 Excel 求和公式") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-excel-sum-formula) | Hard |
563574
| <span id="630">630</span> | [Course Schedule III](https://leetcode.com/problems/course-schedule-iii "课程表 III") | [Go](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii) | Hard |
564575
| <span id="629">629</span> | [K Inverse Pairs Array](https://leetcode.com/problems/k-inverse-pairs-array "K个逆序对数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-inverse-pairs-array) | Hard |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/n-th-tribonacci-number "N-th Tribonacci Number")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square "Largest 1-Bordered Square")
11+
12+
## 1138. Alphabet Board Path (Medium)
13+
14+
<p>On an alphabet board, we start at position <code>(0, 0)</code>, corresponding to character&nbsp;<code>board[0][0]</code>.</p>
15+
16+
<p>Here, <code>board = [&quot;abcde&quot;, &quot;fghij&quot;, &quot;klmno&quot;, &quot;pqrst&quot;, &quot;uvwxy&quot;, &quot;z&quot;]</code>, as shown in the diagram below.</p>
17+
18+
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/07/28/azboard.png" style="width: 250px; height: 317px;" /></p>
19+
20+
<p>We may make the following moves:</p>
21+
22+
<ul>
23+
<li><code>&#39;U&#39;</code> moves our position up one row, if the position exists on the board;</li>
24+
<li><code>&#39;D&#39;</code> moves our position down one row, if the position exists on the board;</li>
25+
<li><code>&#39;L&#39;</code> moves our position left one column, if the position exists on the board;</li>
26+
<li><code>&#39;R&#39;</code> moves our position right one column, if the position exists on the board;</li>
27+
<li><code>&#39;!&#39;</code>&nbsp;adds the character <code>board[r][c]</code> at our current position <code>(r, c)</code>&nbsp;to the&nbsp;answer.</li>
28+
</ul>
29+
30+
<p>(Here, the only positions that exist on the board are positions with letters on them.)</p>
31+
32+
<p>Return a sequence of moves that makes our answer equal to <code>target</code>&nbsp;in the minimum number of moves.&nbsp; You may return any path that does so.</p>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Example 1:</strong></p>
36+
<pre><strong>Input:</strong> target = "leet"
37+
<strong>Output:</strong> "DDR!UURRR!!DDD!"
38+
</pre><p><strong>Example 2:</strong></p>
39+
<pre><strong>Input:</strong> target = "code"
40+
<strong>Output:</strong> "RR!DDRR!UUL!R!"
41+
</pre>
42+
<p>&nbsp;</p>
43+
<p><strong>Constraints:</strong></p>
44+
45+
<ul>
46+
<li><code>1 &lt;= target.length &lt;= 100</code></li>
47+
<li><code>target</code> consists only of English lowercase letters.</li>
48+
</ul>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag "Decrease Elements To Make Array Zigzag")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/snapshot-array "Snapshot Array")
11+
12+
## 1145. Binary Tree Coloring Game (Medium)
13+
14+
<p>Two players play a turn based game on a binary tree.&nbsp; We are given&nbsp;the <code>root</code> of this binary tree, and the number of nodes <code>n</code>&nbsp;in the tree.&nbsp; <code>n</code> is odd, and&nbsp;each node has a distinct value from <code>1</code> to <code>n</code>.</p>
15+
16+
<p>Initially, the first player names a value <code>x</code> with <code>1 &lt;= x &lt;= n</code>, and the second player names a value <code>y</code> with <code>1 &lt;= y &lt;= n</code> and <code>y != x</code>.&nbsp; The first player colors the node with value <code>x</code> red, and the second player colors the node with value <code>y</code> blue.</p>
17+
18+
<p>Then, the players take turns starting with the first player.&nbsp; In each turn, that player chooses a node of their color (red if player 1, blue if player 2) and colors an <strong>uncolored</strong> neighbor of the chosen node (either the left child, right child, or parent of the chosen node.)</p>
19+
20+
<p>If (and only if)&nbsp;a player cannot choose such a node in this way, they must pass their turn.&nbsp; If both players pass their turn, the game ends, and the winner is the player that colored more nodes.</p>
21+
22+
<p>You are the second player.&nbsp; If it is possible to choose such a <code>y</code>&nbsp;to ensure you win the game, return <code>true</code>.&nbsp; If it is not possible, return <code>false</code>.</p>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Example 1:</strong></p>
26+
<img alt="" src="https://assets.leetcode.com/uploads/2019/08/01/1480-binary-tree-coloring-game.png" style="width: 300px; height: 186px;" />
27+
<pre>
28+
<strong>Input:</strong> root = [1,2,3,4,5,6,7,8,9,10,11], n = 11, x = 3
29+
<strong>Output:</strong> true
30+
<strong>Explanation: </strong>The second player can choose the node with value 2.
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li><code>root</code> is the root of a binary tree with <code>n</code> nodes and distinct node values from <code>1</code> to <code>n</code>.</li>
38+
<li><code>n</code> is odd.</li>
39+
<li><code>1 &lt;= x &lt;= n&nbsp;&lt;= 100</code></li>
40+
</ul>
41+
42+
### Related Topics
43+
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
44+
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence "Longest Common Subsequence")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game "Binary Tree Coloring Game")
11+
12+
## 1144. Decrease Elements To Make Array Zigzag (Medium)
13+
14+
<p>Given an array <code>nums</code> of integers, a <em>move</em>&nbsp;consists of choosing any element and <strong>decreasing it by 1</strong>.</p>
15+
16+
<p>An array <code>A</code> is a&nbsp;<em>zigzag array</em>&nbsp;if either:</p>
17+
18+
<ul>
19+
<li>Every even-indexed element is greater than adjacent elements, ie.&nbsp;<code>A[0] &gt; A[1] &lt; A[2] &gt; A[3] &lt; A[4] &gt; ...</code></li>
20+
<li>OR, every odd-indexed element is greater than adjacent elements, ie.&nbsp;<code>A[0] &lt; A[1] &gt; A[2] &lt; A[3] &gt; A[4] &lt; ...</code></li>
21+
</ul>
22+
23+
<p>Return the minimum number of moves to transform the given array <code>nums</code> into a zigzag array.</p>
24+
25+
<p>&nbsp;</p>
26+
<p><strong>Example 1:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> nums = [1,2,3]
30+
<strong>Output:</strong> 2
31+
<strong>Explanation:</strong> We can decrease 2 to 0 or 3 to 1.
32+
</pre>
33+
34+
<p><strong>Example 2:</strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> nums = [9,6,1,6,2]
38+
<strong>Output:</strong> 4
39+
</pre>
40+
41+
<p>&nbsp;</p>
42+
<p><strong>Constraints:</strong></p>
43+
44+
<ul>
45+
<li><code>1 &lt;= nums.length &lt;= 1000</code></li>
46+
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
47+
</ul>
48+
49+
### Related Topics
50+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]

‎problems/design-excel-sum-formula/README.md‎

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

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/course-schedule-iii "Course Schedule III")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-range "Smallest Range")
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/smallest-range-covering-elements-from-k-lists "Smallest Range Covering Elements from K Lists")
1111

1212
## 631. Design Excel Sum Formula (Hard)
1313

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/alphabet-board-path "Alphabet Board Path")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii "Stone Game II")
11+
12+
## 1139. Largest 1-Bordered Square (Medium)
13+
14+
<p>Given a 2D <code>grid</code> of <code>0</code>s and <code>1</code>s, return the number of elements in&nbsp;the largest <strong>square</strong>&nbsp;subgrid that has all <code>1</code>s on its <strong>border</strong>, or <code>0</code> if such a subgrid&nbsp;doesn&#39;t exist in the <code>grid</code>.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong>Example 1:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> grid = [[1,1,1],[1,0,1],[1,1,1]]
21+
<strong>Output:</strong> 9
22+
</pre>
23+
24+
<p><strong>Example 2:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> grid = [[1,1,0,0]]
28+
<strong>Output:</strong> 1
29+
</pre>
30+
31+
<p>&nbsp;</p>
32+
<p><strong>Constraints:</strong></p>
33+
34+
<ul>
35+
<li><code>1 &lt;= grid.length &lt;= 100</code></li>
36+
<li><code>1 &lt;= grid[0].length &lt;= 100</code></li>
37+
<li><code>grid[i][j]</code> is <code>0</code> or <code>1</code></li>
38+
</ul>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /