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
+15-5Lines changed: 15 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,23 +70,33 @@ LeetCode Problems' Solutions
70
70
71
71
| # | Title | Solution | Difficulty |
72
72
| :-: | - | - | :-: |
73
-
| <spanid="1612">1612</span> |[Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent) 🔒 |[Go](problems/check-if-two-expression-trees-are-equivalent)| Medium |
73
+
| <spanid="1622">1622</span> |[Fancy Sequence](https://leetcode.com/problems/fancy-sequence"奇妙序列")|[Go](problems/fancy-sequence)| Hard |
74
+
| <spanid="1621">1621</span> |[Number of Sets of K Non-Overlapping Line Segments](https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments"大小为 K 的不重叠线段的数目")|[Go](problems/number-of-sets-of-k-non-overlapping-line-segments)| Medium |
75
+
| <spanid="1620">1620</span> |[Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality"网络信号最好的坐标")|[Go](problems/coordinate-with-maximum-network-quality)| Medium |
76
+
| <spanid="1619">1619</span> |[Mean of Array After Removing Some Elements](https://leetcode.com/problems/mean-of-array-after-removing-some-elements"删除某些元素后的数组均值")|[Go](problems/mean-of-array-after-removing-some-elements)| Easy |
77
+
| <spanid="1618">1618</span> |[Maximum Font to Fit a Sentence in a Screen](https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen"找出适应屏幕的最大字号") 🔒 |[Go](problems/maximum-font-to-fit-a-sentence-in-a-screen)| Medium |
78
+
| <spanid="1617">1617</span> |[Count Subtrees With Max Distance Between Cities](https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities"统计子树中城市之间最大距离")|[Go](problems/count-subtrees-with-max-distance-between-cities)| Hard |
79
+
| <spanid="1616">1616</span> |[Split Two Strings to Make Palindrome](https://leetcode.com/problems/split-two-strings-to-make-palindrome"分割两个字符串得到回文串")|[Go](problems/split-two-strings-to-make-palindrome)| Medium |
80
+
| <spanid="1615">1615</span> |[Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank"最大网络秩")|[Go](problems/maximal-network-rank)| Medium |
81
+
| <spanid="1614">1614</span> |[Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses"括号的最大嵌套深度")|[Go](problems/maximum-nesting-depth-of-the-parentheses)| Easy |
82
+
| <spanid="1613">1613</span> |[Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids"找到遗失的ID") 🔒 |[MySQL](problems/find-the-missing-ids)| Medium |
83
+
| <spanid="1612">1612</span> |[Check If Two Expression Trees are Equivalent](https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent"检查两棵二叉表达式树是否等价") 🔒 |[Go](problems/check-if-two-expression-trees-are-equivalent)| Medium |
74
84
| <spanid="1611">1611</span> |[Minimum One Bit Operations to Make Integers Zero](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero"使整数变为 0 的最少操作次数")|[Go](problems/minimum-one-bit-operations-to-make-integers-zero)| Hard |
75
85
| <spanid="1610">1610</span> |[Maximum Number of Visible Points](https://leetcode.com/problems/maximum-number-of-visible-points"可见点的最大数目")|[Go](problems/maximum-number-of-visible-points)| Hard |
76
86
| <spanid="1609">1609</span> |[Even Odd Tree](https://leetcode.com/problems/even-odd-tree"奇偶树")|[Go](problems/even-odd-tree)| Medium |
77
87
| <spanid="1608">1608</span> |[Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x"特殊数组的特征值")|[Go](problems/special-array-with-x-elements-greater-than-or-equal-x)| Easy |
78
-
| <spanid="1607">1607</span> |[Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales) 🔒 |[MySQL](problems/sellers-with-no-sales)| Easy |
88
+
| <spanid="1607">1607</span> |[Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales"没有卖出的卖家") 🔒 |[MySQL](problems/sellers-with-no-sales)| Easy |
79
89
| <spanid="1606">1606</span> |[Find Servers That Handled Most Number of Requests](https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests"找到处理最多请求的服务器")|[Go](problems/find-servers-that-handled-most-number-of-requests)| Hard |
80
90
| <spanid="1605">1605</span> |[Find Valid Matrix Given Row and Column Sums](https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums"给定行和列的和求可行矩阵")|[Go](problems/find-valid-matrix-given-row-and-column-sums)| Medium |
81
91
| <spanid="1604">1604</span> |[Alert Using Same Key-Card Three or More Times in a One Hour Period](https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period"警告一小时内使用相同员工卡大于等于三次的人")|[Go](problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period)| Medium |
| <spanid="1602">1602</span> |[Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree) 🔒 |[Go](problems/find-nearest-right-node-in-binary-tree)| Medium |
93
+
| <spanid="1602">1602</span> |[Find Nearest Right Node in Binary Tree](https://leetcode.com/problems/find-nearest-right-node-in-binary-tree"找到二叉树中最近的右侧节点") 🔒 |[Go](problems/find-nearest-right-node-in-binary-tree)| Medium |
84
94
| <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 |
85
95
| <spanid="1600">1600</span> |[Throne Inheritance](https://leetcode.com/problems/throne-inheritance"皇位继承顺序")|[Go](problems/throne-inheritance)| Medium |
86
96
| <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)| Hard |
89
-
| <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 |
99
+
| <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 |
90
100
| <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 |
91
101
| <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 |
92
102
| <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 |
@@ -95,7 +105,7 @@ LeetCode Problems' Solutions
95
105
| <spanid="1590">1590</span> |[Make Sum Divisible by P](https://leetcode.com/problems/make-sum-divisible-by-p"使数组和能被 P 整除")|[Go](problems/make-sum-divisible-by-p)| Medium |
96
106
| <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 |
97
107
| <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"二叉搜索树迭代器 II") 🔒 |[Go](problems/binary-search-tree-iterator-ii)| Medium |
100
110
| <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 |
101
111
| <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 |
Copy file name to clipboardExpand all lines: problems/132-pattern/README.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,9 @@
13
13
14
14
<p>Given an array of <code>n</code> integers <code>nums</code>, a <strong>132 pattern</strong> is a subsequence of three integers <code>nums[i]</code>, <code>nums[j]</code> and <code>nums[k]</code> such that <code>i < j < k</code> and <code>nums[i] < nums[k] < nums[j]</code>.</p>
15
15
16
-
<p>Return <em><code>true</code> if there is a <strong>132 pattern</strong> in <code>nums</code>, otherwise return <code>false</code>.</em></p>
16
+
<p>Return <em><code>true</code> if there is a <strong>132 pattern</strong> in <code>nums</code>, otherwise, return <code>false</code>.</em></p>
17
+
18
+
<p><strong>Follow up: </strong>The <code>O(n^2)</code> is trivial, could you come up with the <code>O(n logn)</code> or the <code>O(n)</code> solution?</p>
17
19
18
20
<p> </p>
19
21
<p><strong>Example 1:</strong></p>
@@ -45,7 +47,7 @@
45
47
46
48
<ul>
47
49
<li><code>n == nums.length</code></li>
48
-
<li><code>1 <= n <= 3 * 10<sup>4</sup></code></li>
50
+
<li><code>1 <= n <= 10<sup>4</sup></code></li>
Copy file name to clipboardExpand all lines: problems/assign-cookies/README.md
+23-20Lines changed: 23 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,38 +11,41 @@
11
11
12
12
## [455. Assign Cookies (Easy)](https://leetcode.com/problems/assign-cookies"分发饼干")
13
13
14
-
<p>
15
-
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g<sub>i</sub>, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s<sub>j</sub>. If s<sub>j</sub> >= g<sub>i</sub>, we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.
16
-
</p>
14
+
<p>Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.</p>
17
15
18
-
<p><b>Note:</b><br />
19
-
You may assume the greed factor is always positive. <br />
20
-
You cannot assign more than one cookie to one child.
21
-
</p>
16
+
<p>Each child <code>i</code> has a greed factor <code>g[i]</code>, which is the minimum size of a cookie that the child will be content with; and each cookie <code>j</code> has a size <code>s[j]</code>. If <code>s[j] >= g[i]</code>, we can assign the cookie <code>j</code> to the child <code>i</code>, and the child <code>i</code> will be content. Your goal is to maximize the number of your content children and output the maximum number.</p>
22
17
23
-
<p><b>Example 1:</b><br />
24
-
<pre>
25
-
<b>Input:</b> [1,2,3], [1,1]
18
+
<p> </p>
26
19
27
-
<b>Output:</b> 1
20
+
<p> </p>
21
+
<p><strong>Example 1:</strong></p>
28
22
29
-
<b>Explanation:</b> You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3.
23
+
<pre>
24
+
<strong>Input:</strong> g = [1,2,3], s = [1,1]
25
+
<strong>Output:</strong> 1
26
+
<strong>Explanation:</strong> You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3.
30
27
And even though you have 2 cookies, since their size is both 1, you could only make the child whose greed factor is 1 content.
31
28
You need to output 1.
32
29
</pre>
33
-
</p>
34
-
35
-
<p><b>Example 2:</b><br />
36
-
<pre>
37
-
<b>Input:</b> [1,2], [1,2,3]
38
30
39
-
<b>Output:</b> 2
31
+
<p><strong>Example 2:</strong></p>
40
32
41
-
<b>Explanation:</b> You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2.
33
+
<pre>
34
+
<strong>Input:</strong> g = [1,2], s = [1,2,3]
35
+
<strong>Output:</strong> 2
36
+
<strong>Explanation:</strong> You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2.
42
37
You have 3 cookies and their sizes are big enough to gratify all of the children,
Copy file name to clipboardExpand all lines: problems/asteroid-collision/README.md
+35-41Lines changed: 35 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,59 +11,53 @@
11
11
12
12
## [735. Asteroid Collision (Medium)](https://leetcode.com/problems/asteroid-collision"行星碰撞")
13
13
14
-
<p>
15
-
We are given an array <code>asteroids</code> of integers representing asteroids in a row.
16
-
</p><p>
17
-
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
18
-
</p><p>
19
-
Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.
20
-
</p>
21
-
22
-
<p><b>Example 1:</b><br />
14
+
<p>We are given an array <code>asteroids</code> of integers representing asteroids in a row.</p>
15
+
16
+
<p>For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.</p>
17
+
18
+
<p>Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.</p>
19
+
20
+
<p> </p>
21
+
<p><strong>Example 1:</strong></p>
22
+
23
23
<pre>
24
-
<b>Input:</b>
25
-
asteroids = [5, 10, -5]
26
-
<b>Output:</b> [5, 10]
27
-
<b>Explanation:</b>
28
-
The 10 and -5 collide resulting in 10. The 5 and 10 never collide.
24
+
<strong>Input:</strong> asteroids = [5,10,-5]
25
+
<strong>Output:</strong> [5,10]
26
+
<b>Explanation:</b> The 10 and -5 collide resulting in 10. The 5 and 10 never collide.
29
27
</pre>
30
-
</p>
31
28
32
-
<p><b>Example 2:</b><br />
29
+
<p><strong>Example 2:</strong></p>
30
+
33
31
<pre>
34
-
<b>Input:</b>
35
-
asteroids = [8, -8]
36
-
<b>Output:</b> []
37
-
<b>Explanation:</b>
38
-
The 8 and -8 collide exploding each other.
32
+
<strong>Input:</strong> asteroids = [8,-8]
33
+
<strong>Output:</strong> []
34
+
<b>Explanation:</b> The 8 and -8 collide exploding each other.
39
35
</pre>
40
-
</p>
41
36
42
-
<p><b>Example 3:</b><br />
37
+
<p><strong>Example 3:</strong></p>
38
+
43
39
<pre>
44
-
<b>Input:</b>
45
-
asteroids = [10, 2, -5]
46
-
<b>Output:</b> [10]
47
-
<b>Explanation:</b>
48
-
The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.
40
+
<strong>Input:</strong> asteroids = [10,2,-5]
41
+
<strong>Output:</strong> [10]
42
+
<b>Explanation:</b> The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.
49
43
</pre>
50
-
</p>
51
44
52
-
<p><b>Example 4:</b><br />
45
+
<p><strong>Example 4:</strong></p>
46
+
53
47
<pre>
54
-
<b>Input:</b>
55
-
asteroids = [-2, -1, 1, 2]
56
-
<b>Output:</b> [-2, -1, 1, 2]
57
-
<b>Explanation:</b>
58
-
The -2 and -1 are moving left, while the 1 and 2 are moving right.
59
-
Asteroids moving the same direction never meet, so no asteroids will meet each other.
48
+
<strong>Input:</strong> asteroids = [-2,-1,1,2]
49
+
<strong>Output:</strong> [-2,-1,1,2]
50
+
<b>Explanation:</b> The -2 and -1 are moving left, while the 1 and 2 are moving right. Asteroids moving the same direction never meet, so no asteroids will meet each other.
60
51
</pre>
61
-
</p>
62
52
63
-
<p><b>Note:</b>
64
-
<li>The length of <code>asteroids</code> will be at most <code>10000</code>.</li>
65
-
<li>Each asteroid will be a non-zero integer in the range <code>[-1000, 1000].</code>.</li>
0 commit comments