You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,12 @@ LeetCode Problems' Solutions
70
70
71
71
| # | Title | Solution | Difficulty |
72
72
| :-: | - | - | :-: |
73
+
| <spanid="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
+
| <spanid="1600">1600</span> |[Throne Inheritance](https://leetcode.com/problems/throne-inheritance"皇位继承顺序")|[Go](problems/throne-inheritance)| Medium |
75
+
| <spanid="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 |
| <spanid="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
+
| <spanid="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 |
73
79
| <spanid="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 |
74
80
| <spanid="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 |
75
81
| <spanid="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
79
85
| <spanid="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 |
80
86
| <spanid="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 |
| <spanid="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
+
| <spanid="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 |
83
89
| <spanid="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 |
84
90
| <spanid="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 |
85
91
| <spanid="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
94
100
| <spanid="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 |
95
101
| <spanid="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 |
| <spanid="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 |
99
105
| <spanid="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 |
100
106
| <spanid="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
116
122
| <spanid="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 |
117
123
| <spanid="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 |
| <spanid="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
+
| <spanid="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 |
120
126
| <spanid="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 |
121
127
| <spanid="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 |
122
128
| <spanid="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 |
| <spanid="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 |
128
134
| <spanid="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 |
129
135
| <spanid="1539">1539</span> |[Kth Missing Positive Number](https://leetcode.com/problems/kth-missing-positive-number"第 k 个缺失的正整数")|[Go](problems/kth-missing-positive-number)| Easy |
130
-
| <spanid="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
+
| <spanid="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 |
131
137
| <spanid="1537">1537</span> |[Get the Maximum Score](https://leetcode.com/problems/get-the-maximum-score"最大得分")|[Go](problems/get-the-maximum-score)| Hard |
132
138
| <spanid="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 |
133
139
| <spanid="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 |
134
140
| <spanid="1534">1534</span> |[Count Good Triplets](https://leetcode.com/problems/count-good-triplets"统计好三元组")|[Go](problems/count-good-triplets)| Easy |
135
-
| <spanid="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
+
| <spanid="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 |
136
142
| <spanid="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 |
137
143
| <spanid="1531">1531</span> |[String Compression II](https://leetcode.com/problems/string-compression-ii"压缩字符串 II")|[Go](problems/string-compression-ii)| Hard |
138
144
| <spanid="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
165
171
| <spanid="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 |
166
172
| <spanid="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 |
167
173
| <spanid="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
-
| <spanid="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
+
| <spanid="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 |
169
175
| <spanid="1499">1499</span> |[Max Value of Equation](https://leetcode.com/problems/max-value-of-equation"满足不等式的最大值")|[Go](problems/max-value-of-equation)| Hard |
170
176
| <spanid="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 |
171
177
| <spanid="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 |
Copy file name to clipboardExpand all lines: problems/adding-two-negabinary-numbers/README.md
+23-13Lines changed: 23 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -13,31 +13,41 @@
13
13
14
14
<p>Given two numbers <code>arr1</code> and <code>arr2</code> in base <strong>-2</strong>, return the result of adding them together.</p>
15
15
16
-
<p>Each number is given in <em>array format</em>: as an array of 0s and 1s, from most significant bit to least significant bit. For example, <code>arr = [1,1,0,1]</code> represents the number <code>(-2)^3 + (-2)^2 + (-2)^0 = -3</code>. A number <code>arr</code> in <em>array format</em> is also guaranteed to have no leading zeros: either <code>arr == [0]</code> or <code>arr[0] == 1</code>.</p>
16
+
<p>Each number is given in <em>array format</em>: as an array of 0s and 1s, from most significant bit to least significant bit. For example, <code>arr = [1,1,0,1]</code> represents the number <code>(-2)^3 + (-2)^2 + (-2)^0 = -3</code>. A number <code>arr</code> in <em>array, format</em> is also guaranteed to have no leading zeros: either <code>arr == [0]</code> or <code>arr[0] == 1</code>.</p>
17
17
18
18
<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>
Copy file name to clipboardExpand all lines: problems/binary-search-tree-to-greater-sum-tree/README.md
+33-21Lines changed: 33 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -9,46 +9,58 @@
9
9
10
10
[Next >](../minimum-score-triangulation-of-polygon"Minimum Score Triangulation of Polygon")
11
11
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"把二叉搜索树转换为累加树")
13
13
14
-
<p>Given the root of a binary <strong>search</strong> tree with distinct values, modify it so that every <code>node</code> 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>
15
15
16
-
<p>As a reminder, a <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>
17
17
18
18
<ul>
19
19
<li>The left subtree of a node contains only nodes with keys <strong>less than</strong> the node's key.</li>
20
20
<li>The right subtree of a node contains only nodes with keys <strong>greater than</strong> the node's key.</li>
21
21
<li>Both the left and right subtrees must also be binary search trees.</li>
22
22
</ul>
23
23
24
-
<p> </p>
24
+
<p><strong>Note:</strong> This question is the same as 538: <ahref="https://leetcode.com/problems/convert-bst-to-greater-tree/">https://leetcode.com/problems/convert-bst-to-greater-tree/</a></p>
<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: <ahref="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 <= Node.val <= 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>
0 commit comments