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 59e29e3

Browse files
author
Shuo
authored
Merge pull request #816 from openset/develop
A: new
2 parents da2d2f0 + 177c833 commit 59e29e3

File tree

59 files changed

+1002
-260
lines changed

Some content is hidden

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

59 files changed

+1002
-260
lines changed

‎README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ LeetCode Problems' Solutions
7070

7171
| # | Title | Solution | Difficulty |
7272
| :-: | - | - | :-: |
73+
| <span id="1601">1601</span> | [Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests "最多可达成的换楼请求数目") | [Go](problems/maximum-number-of-achievable-transfer-requests) | Hard |
74+
| <span id="1600">1600</span> | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium |
75+
| <span id="1599">1599</span> | [Maximum Profit of Operating a Centennial Wheel](https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel "经营摩天轮的最大利润") | [Go](problems/maximum-profit-of-operating-a-centennial-wheel) | Medium |
76+
| <span id="1598">1598</span> | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy |
77+
| <span id="1597">1597</span> | [Build Binary Expression Tree From Infix Expression](https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression) 🔒 | [Go](problems/build-binary-expression-tree-from-infix-expression) | Medium |
78+
| <span id="1596">1596</span> | [The Most Frequently Ordered Products for Each Customer](https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer) 🔒 | [MySQL](problems/the-most-frequently-ordered-products-for-each-customer) | Medium |
7379
| <span id="1595">1595</span> | [Minimum Cost to Connect Two Groups of Points](https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points "连通两组点的最小成本") | [Go](problems/minimum-cost-to-connect-two-groups-of-points) | Hard |
7480
| <span id="1594">1594</span> | [Maximum Non Negative Product in a Matrix](https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix "矩阵的最大非负积") | [Go](problems/maximum-non-negative-product-in-a-matrix) | Medium |
7581
| <span id="1593">1593</span> | [Split a String Into the Max Number of Unique Substrings](https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings "拆分字符串使唯一子字符串的数目最大") | [Go](problems/split-a-string-into-the-max-number-of-unique-substrings) | Medium |
@@ -79,7 +85,7 @@ LeetCode Problems' Solutions
7985
| <span id="1589">1589</span> | [Maximum Sum Obtained of Any Permutation](https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation "所有排列中的最大和") | [Go](problems/maximum-sum-obtained-of-any-permutation) | Medium |
8086
| <span id="1588">1588</span> | [Sum of All Odd Length Subarrays](https://leetcode.com/problems/sum-of-all-odd-length-subarrays "所有奇数长度子数组的和") | [Go](problems/sum-of-all-odd-length-subarrays) | Easy |
8187
| <span id="1587">1587</span> | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii) 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy |
82-
| <span id="1586">1586</span> | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii) 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium |
88+
| <span id="1586">1586</span> | [Binary Search Tree Iterator II](https://leetcode.com/problems/binary-search-tree-iterator-ii"二叉搜索树迭代器 II") 🔒 | [Go](problems/binary-search-tree-iterator-ii) | Medium |
8389
| <span id="1585">1585</span> | [Check If String Is Transformable With Substring Sort Operations](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations "检查字符串是否可以通过排序子字符串得到另一个字符串") | [Go](problems/check-if-string-is-transformable-with-substring-sort-operations) | Hard |
8490
| <span id="1584">1584</span> | [Min Cost to Connect All Points](https://leetcode.com/problems/min-cost-to-connect-all-points "连接所有点的最小费用") | [Go](problems/min-cost-to-connect-all-points) | Medium |
8591
| <span id="1583">1583</span> | [Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends "统计不开心的朋友") | [Go](problems/count-unhappy-friends) | Medium |
@@ -94,7 +100,7 @@ LeetCode Problems' Solutions
94100
| <span id="1574">1574</span> | [Shortest Subarray to be Removed to Make Array Sorted](https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted "删除最短的子数组使剩余数组有序") | [Go](problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium |
95101
| <span id="1573">1573</span> | [Number of Ways to Split a String](https://leetcode.com/problems/number-of-ways-to-split-a-string "分割字符串的方案数") | [Go](problems/number-of-ways-to-split-a-string) | Medium |
96102
| <span id="1572">1572</span> | [Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum "矩阵对角线元素的和") | [Go](problems/matrix-diagonal-sum) | Easy |
97-
| <span id="1571">1571</span> | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager) 🔒 | [MySQL](problems/warehouse-manager) | Easy |
103+
| <span id="1571">1571</span> | [Warehouse Manager](https://leetcode.com/problems/warehouse-manager"仓库经理") 🔒 | [MySQL](problems/warehouse-manager) | Easy |
98104
| <span id="1570">1570</span> | [Dot Product of Two Sparse Vectors](https://leetcode.com/problems/dot-product-of-two-sparse-vectors) 🔒 | [Go](problems/dot-product-of-two-sparse-vectors) | Medium |
99105
| <span id="1569">1569</span> | [Number of Ways to Reorder Array to Get Same BST](https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst "将子数组重新排序得到同一个二叉查找树的方案数") | [Go](problems/number-of-ways-to-reorder-array-to-get-same-bst) | Hard |
100106
| <span id="1568">1568</span> | [Minimum Number of Days to Disconnect Island](https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island "使陆地分离的最少天数") | [Go](problems/minimum-number-of-days-to-disconnect-island) | Hard |
@@ -116,7 +122,7 @@ LeetCode Problems' Solutions
116122
| <span id="1552">1552</span> | [Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls "两球之间的磁力") | [Go](problems/magnetic-force-between-two-balls) | Medium |
117123
| <span id="1551">1551</span> | [Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal "使数组中所有元素相等的最小操作数") | [Go](problems/minimum-operations-to-make-array-equal) | Medium |
118124
| <span id="1550">1550</span> | [Three Consecutive Odds](https://leetcode.com/problems/three-consecutive-odds "存在连续三个奇数的数组") | [Go](problems/three-consecutive-odds) | Easy |
119-
| <span id="1549">1549</span> | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product) 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium |
125+
| <span id="1549">1549</span> | [The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product"每件商品的最新订单") 🔒 | [MySQL](problems/the-most-recent-orders-for-each-product) | Medium |
120126
| <span id="1548">1548</span> | [The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph) 🔒 | [Go](problems/the-most-similar-path-in-a-graph) | Hard |
121127
| <span id="1547">1547</span> | [Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick "切棍子的最小成本") | [Go](problems/minimum-cost-to-cut-a-stick) | Hard |
122128
| <span id="1546">1546</span> | [Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target "和为目标值的最大数目不重叠非空子数组数目") | [Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target) | Medium |
@@ -127,12 +133,12 @@ LeetCode Problems' Solutions
127133
| <span id="1541">1541</span> | [Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string "平衡括号字符串的最少插入次数") | [Go](problems/minimum-insertions-to-balance-a-parentheses-string) | Medium |
128134
| <span id="1540">1540</span> | [Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves "K 次操作转变字符串") | [Go](problems/can-convert-string-in-k-moves) | Medium |
129135
| <span id="1539">1539</span> | [Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number "第 k 个缺失的正整数") | [Go](problems/kth-missing-positive-number) | Easy |
130-
| <span id="1538">1538</span> | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array) 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium |
136+
| <span id="1538">1538</span> | [Guess the Majority in a Hidden Array](https://leetcode.com/problems/guess-the-majority-in-a-hidden-array"找出隐藏数组中出现次数最多的元素") 🔒 | [Go](problems/guess-the-majority-in-a-hidden-array) | Medium |
131137
| <span id="1537">1537</span> | [Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score "最大得分") | [Go](problems/get-the-maximum-score) | Hard |
132138
| <span id="1536">1536</span> | [Minimum Swaps to Arrange a Binary Grid](https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid "排布二进制网格的最少交换次数") | [Go](problems/minimum-swaps-to-arrange-a-binary-grid) | Medium |
133139
| <span id="1535">1535</span> | [Find the Winner of an Array Game](https://leetcode.com/problems/find-the-winner-of-an-array-game "找出数组游戏的赢家") | [Go](problems/find-the-winner-of-an-array-game) | Medium |
134140
| <span id="1534">1534</span> | [Count Good Triplets](https://leetcode.com/problems/count-good-triplets "统计好三元组") | [Go](problems/count-good-triplets) | Easy |
135-
| <span id="1533">1533</span> | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer) 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium |
141+
| <span id="1533">1533</span> | [Find the Index of the Large Integer](https://leetcode.com/problems/find-the-index-of-the-large-integer"找到最大整数的索引") 🔒 | [Go](problems/find-the-index-of-the-large-integer) | Medium |
136142
| <span id="1532">1532</span> | [The Most Recent Three Orders](https://leetcode.com/problems/the-most-recent-three-orders "最近的三笔订单") 🔒 | [MySQL](problems/the-most-recent-three-orders) | Medium |
137143
| <span id="1531">1531</span> | [String Compression II](https://leetcode.com/problems/string-compression-ii "压缩字符串 II") | [Go](problems/string-compression-ii) | Hard |
138144
| <span id="1530">1530</span> | [Number of Good Leaf Nodes Pairs](https://leetcode.com/problems/number-of-good-leaf-nodes-pairs "好叶子节点对的数量") | [Go](problems/number-of-good-leaf-nodes-pairs) | Medium |
@@ -165,7 +171,7 @@ LeetCode Problems' Solutions
165171
| <span id="1503">1503</span> | [Last Moment Before All Ants Fall Out of a Plank](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank "所有蚂蚁掉下来前的最后一刻") | [Go](problems/last-moment-before-all-ants-fall-out-of-a-plank) | Medium |
166172
| <span id="1502">1502</span> | [Can Make Arithmetic Progression From Sequence](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence "判断能否形成等差数列") | [Go](problems/can-make-arithmetic-progression-from-sequence) | Easy |
167173
| <span id="1501">1501</span> | [Countries You Can Safely Invest In](https://leetcode.com/problems/countries-you-can-safely-invest-in "可以放心投资的国家") 🔒 | [MySQL](problems/countries-you-can-safely-invest-in) | Medium |
168-
| <span id="1500">1500</span> | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system) 🔒 | [Go](problems/design-a-file-sharing-system) | Medium |
174+
| <span id="1500">1500</span> | [Design a File Sharing System](https://leetcode.com/problems/design-a-file-sharing-system"设计文件分享系统") 🔒 | [Go](problems/design-a-file-sharing-system) | Medium |
169175
| <span id="1499">1499</span> | [Max Value of Equation](https://leetcode.com/problems/max-value-of-equation "满足不等式的最大值") | [Go](problems/max-value-of-equation) | Hard |
170176
| <span id="1498">1498</span> | [Number of Subsequences That Satisfy the Given Sum Condition](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition "满足条件的子序列数目") | [Go](problems/number-of-subsequences-that-satisfy-the-given-sum-condition) | Medium |
171177
| <span id="1497">1497</span> | [Check If Array Pairs Are Divisible by k](https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k "检查数组对是否可以被 k 整除") | [Go](problems/check-if-array-pairs-are-divisible-by-k) | Medium |

‎problems/adding-two-negabinary-numbers/README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,41 @@
1313

1414
<p>Given two numbers <code>arr1</code> and <code>arr2</code> in base <strong>-2</strong>, return the result of adding them together.</p>
1515

16-
<p>Each number is given in <em>array format</em>:&nbsp; as an array of 0s and 1s, from most significant bit to least significant bit.&nbsp; For example, <code>arr = [1,1,0,1]</code> represents the number <code>(-2)^3&nbsp;+ (-2)^2 + (-2)^0 = -3</code>.&nbsp; A number <code>arr</code> in <em>array format</em> is also guaranteed to have no leading zeros: either&nbsp;<code>arr == [0]</code> or <code>arr[0] == 1</code>.</p>
16+
<p>Each number is given in <em>array format</em>:&nbsp; as an array of 0s and 1s, from most significant bit to least significant bit.&nbsp; For example, <code>arr = [1,1,0,1]</code> represents the number <code>(-2)^3&nbsp;+ (-2)^2 + (-2)^0 = -3</code>.&nbsp; A number <code>arr</code> in <em>array, format</em> is also guaranteed to have no leading zeros: either&nbsp;<code>arr == [0]</code> or <code>arr[0] == 1</code>.</p>
1717

1818
<p>Return the result of adding <code>arr1</code> and <code>arr2</code> in the same format: as an array of 0s and 1s with no leading zeros.</p>
1919

2020
<p>&nbsp;</p>
21-
2221
<p><strong>Example 1:</strong></p>
2322

2423
<pre>
25-
<strong>Input:</strong>arr1 = <spanid="example-input-1-1">[1,1,1,1,1]</span>, arr2 = <spanid="example-input-1-2">[1,0,1]</span>
26-
<strong>Output:</strong><spanid="example-output-1">[1,0,0,0,0]
27-
</span><strong>Explanation: </strong>arr1 represents 11, arr2 represents 5, the output represents 16.
24+
<strong>Input:</strong>arr1 = [1,1,1,1,1], arr2 = [1,0,1]
25+
<strong>Output:</strong>[1,0,0,0,0]
26+
<strong>Explanation: </strong>arr1 represents 11, arr2 represents 5, the output represents 16.
2827
</pre>
2928

30-
<p>&nbsp;</p>
29+
<p><strong>Example 2:</strong></p>
30+
31+
<pre>
32+
<strong>Input:</strong> arr1 = [0], arr2 = [0]
33+
<strong>Output:</strong> [0]
34+
</pre>
3135

32-
<p><strong>Note:</strong></p>
36+
<p><strong>Example 3:</strong></p>
37+
38+
<pre>
39+
<strong>Input:</strong> arr1 = [0], arr2 = [1]
40+
<strong>Output:</strong> [1]
41+
</pre>
42+
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
3345

34-
<ol>
35-
<li><code>1 &lt;= arr1.length &lt;= 1000</code></li>
36-
<li><code>1 &lt;= arr2.length &lt;= 1000</code></li>
46+
<ul>
47+
<li><code>1 &lt;= arr1.length,&nbsp;arr2.length &lt;= 1000</code></li>
48+
<li><code>arr1[i]</code>&nbsp;and <code>arr2[i]</code> are&nbsp;<code>0</code> or <code>1</code></li>
3749
<li><code>arr1</code> and <code>arr2</code> have no leading zeros</li>
38-
<li><code>arr1[i]</code> is <code>0</code> or <code>1</code></li>
39-
<li><code>arr2[i]</code> is <code>0</code> or <code>1</code></li>
40-
</ol>
50+
</ul>
4151

4252
### Related Topics
4353
[[Math](../../tag/math/README.md)]

‎problems/binary-search-tree-iterator-ii/README.md

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

1010
[Next >](../bank-account-summary-ii "Bank Account Summary II")
1111

12-
## [1586. Binary Search Tree Iterator II (Medium)](https://leetcode.com/problems/binary-search-tree-iterator-ii "")
12+
## [1586. Binary Search Tree Iterator II (Medium)](https://leetcode.com/problems/binary-search-tree-iterator-ii "二叉搜索树迭代器 II")
1313

1414

1515

‎problems/binary-search-tree-to-greater-sum-tree/README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,58 @@
99

1010
[Next >](../minimum-score-triangulation-of-polygon "Minimum Score Triangulation of Polygon")
1111

12-
## [1038. Binary Search Tree to Greater Sum Tree (Medium)](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "从二叉搜索树到更大和树")
12+
## [1038. Binary Search Tree to Greater Sum Tree (Medium)](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree "把二叉搜索树转换为累加树")
1313

14-
<p>Given the root of a binary <strong>search</strong> tree with distinct values, modify it so that every <code>node</code>&nbsp;has a new value equal to the sum of the values of the original tree that are greater than or equal to <code>node.val</code>.</p>
14+
<p>Given the <code>root</code> of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.</p>
1515

16-
<p>As a reminder, a&nbsp;<em>binary search tree</em> is a tree that satisfies these constraints:</p>
16+
<p>As a reminder, a<em>binary search tree</em> is a tree that satisfies these constraints:</p>
1717

1818
<ul>
1919
<li>The left subtree of a node contains only nodes with keys&nbsp;<strong>less than</strong>&nbsp;the node&#39;s key.</li>
2020
<li>The right subtree of a node contains only nodes with keys&nbsp;<strong>greater than</strong>&nbsp;the node&#39;s key.</li>
2121
<li>Both the left and right subtrees must also be binary search trees.</li>
2222
</ul>
2323

24-
<p>&nbsp;</p>
24+
<p><strong>Note:</strong> This question is the same as 538:&nbsp;<ahref="https://leetcode.com/problems/convert-bst-to-greater-tree/">https://leetcode.com/problems/convert-bst-to-greater-tree/</a></p>
2525

26+
<p>&nbsp;</p>
2627
<p><strong>Example 1:</strong></p>
28+
<img alt="" src="https://assets.leetcode.com/uploads/2019/05/02/tree.png" style="width: 550px; height: 375px;" />
29+
<pre>
30+
<strong>Input:</strong> root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
31+
<strong>Output:</strong> [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]
32+
</pre>
2733

28-
<p><strong><imgalt=""src="https://assets.leetcode.com/uploads/2019/05/02/tree.png"style="width: 280px; height: 191px;" /></strong></p>
34+
<p><strong>Example 2:</strong></p>
2935

3036
<pre>
31-
<strong>Input:</strong><spanid="example-input-1-1">[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]</span>
32-
<strong>Output:</strong><spanid="example-output-1">[30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]</span>
37+
<strong>Input:</strong> root = [0,null,1]
38+
<strong>Output:</strong> [1,null,1]
3339
</pre>
3440

35-
<div>
36-
<p>&nbsp;</p>
37-
</div>
41+
<p><strong>Example 3:</strong></p>
42+
43+
<pre>
44+
<strong>Input:</strong> root = [1,0,2]
45+
<strong>Output:</strong> [3,3,2]
46+
</pre>
3847

48+
<p><strong>Example 4:</strong></p>
49+
50+
<pre>
51+
<strong>Input:</strong> root = [3,2,4,1]
52+
<strong>Output:</strong> [7,9,4,10]
53+
</pre>
54+
55+
<p>&nbsp;</p>
3956
<p><strong>Constraints:</strong></p>
4057

41-
<ol>
42-
<li>The number of nodes in the tree is between <code>1</code> and <code>100</code>.</li>
43-
<li>Each node will have value between <code>0</code> and <code>100</code>.</li>
44-
<li>The given tree is a binary search tree.</li>
45-
</ol>
46-
47-
<div>
48-
<div>
49-
<div><strong>Note:</strong> This question is the same as 538:&nbsp;<a href="https://leetcode.com/problems/convert-bst-to-greater-tree/">https://leetcode.com/problems/convert-bst-to-greater-tree/</a></div>
50-
</div>
51-
</div>
58+
<ul>
59+
<li>The number of nodes in the tree is in the range <code>[1, 100]</code>.</li>
60+
<li><code>0 &lt;= Node.val &lt;= 100</code></li>
61+
<li>All the values in the tree are <strong>unique</strong>.</li>
62+
<li><code>root</code> is guaranteed to be a valid binary search tree.</li>
63+
</ul>
5264

5365
### Related Topics
5466
[[Binary Search Tree](../../tag/binary-search-tree/README.md)]

0 commit comments

Comments
(0)

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