Skip to content

A: new #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,33 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <span id="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 |
| <span id="1622">1622</span> | [Fancy Sequence](https://leetcode.com/problems/fancy-sequence "奇妙序列") | [Go](problems/fancy-sequence) | Hard |
| <span id="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 |
| <span id="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 |
| <span id="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 |
| <span id="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 |
| <span id="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 |
| <span id="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 |
| <span id="1615">1615</span> | [Maximal Network Rank](https://leetcode.com/problems/maximal-network-rank "最大网络秩") | [Go](problems/maximal-network-rank) | Medium |
| <span id="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 |
| <span id="1613">1613</span> | [Find the Missing IDs](https://leetcode.com/problems/find-the-missing-ids "找到遗失的ID") 🔒 | [MySQL](problems/find-the-missing-ids) | Medium |
| <span id="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 |
| <span id="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 |
| <span id="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 |
| <span id="1609">1609</span> | [Even Odd Tree](https://leetcode.com/problems/even-odd-tree "奇偶树") | [Go](problems/even-odd-tree) | Medium |
| <span id="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 |
| <span id="1607">1607</span> | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales) 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy |
| <span id="1607">1607</span> | [Sellers With No Sales](https://leetcode.com/problems/sellers-with-no-sales "没有卖出的卖家") 🔒 | [MySQL](problems/sellers-with-no-sales) | Easy |
| <span id="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 |
| <span id="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 |
| <span id="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 |
| <span id="1603">1603</span> | [Design Parking System](https://leetcode.com/problems/design-parking-system "设计停车系统") | [Go](problems/design-parking-system) | Easy |
| <span id="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 |
| <span id="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 |
| <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 |
| <span id="1600">1600</span> | [Throne Inheritance](https://leetcode.com/problems/throne-inheritance "皇位继承顺序") | [Go](problems/throne-inheritance) | Medium |
| <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 |
| <span id="1598">1598</span> | [Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder "文件夹操作日志搜集器") | [Go](problems/crawler-log-folder) | Easy |
| <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) | Hard |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand All @@ -95,7 +105,7 @@ LeetCode Problems' Solutions
| <span id="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 |
| <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 |
| <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 |
| <span id="1587">1587</span> | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii) 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy |
| <span id="1587">1587</span> | [Bank Account Summary II](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II") 🔒 | [MySQL](problems/bank-account-summary-ii) | Easy |
| <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 |
| <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 |
| <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 |
Expand Down
5 changes: 5 additions & 0 deletions internal/leetcode/problems_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ var problemStatus = map[int]bool{
1185: true,
1189: true,
1221: true,
1408: true,
1417: true,
1422: true,
1436: true,
1455: true,
}

// IsSolved - leetcode.IsSolved
Expand Down
6 changes: 4 additions & 2 deletions problems/132-pattern/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

<p>Given an array&nbsp;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 &lt; j &lt; k</code> and <code>nums[i] &lt; nums[k] &lt; nums[j]</code>.</p>

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

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

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
Expand Down Expand Up @@ -45,7 +47,7 @@

<ul>
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<ul>
<li><code>1 &lt;= keyName.length, keyTime.length &lt;= 10<sup>5</sup></code></li>
<li><code>keyName.length == keyTime.length</code></li>
<li><code>keyTime</code> are in the format <strong>&quot;HH:MM&quot;</strong>.</li>
<li><code>keyTime[i]</code>&nbsp;is in the format <strong>&quot;HH:MM&quot;</strong>.</li>
<li><code>[keyName[i], keyTime[i]]</code> is <strong>unique</strong>.</li>
<li><code>1 &lt;= keyName[i].length &lt;= 10</code></li>
<li><code>keyName[i] contains only lowercase English letters.</code></li>
Expand Down
43 changes: 23 additions & 20 deletions problems/assign-cookies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,41 @@

## [455. Assign Cookies (Easy)](https://leetcode.com/problems/assign-cookies "分发饼干")

<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. 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.
</p>
<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>

<p><b>Note:</b><br />
You may assume the greed factor is always positive. <br />
You cannot assign more than one cookie to one child.
</p>
<p>Each child <code>i</code> has&nbsp;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]&nbsp;&gt;= 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>

<p><b>Example 1:</b><br />
<pre>
<b>Input:</b> [1,2,3], [1,1]
<p>&nbsp;</p>

<b>Output:</b> 1
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<b>Explanation:</b> You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3.
<pre>
<strong>Input:</strong> g = [1,2,3], s = [1,1]
<strong>Output:</strong> 1
<strong>Explanation:</strong> You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3.
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.
You need to output 1.
</pre>
</p>

<p><b>Example 2:</b><br />
<pre>
<b>Input:</b> [1,2], [1,2,3]

<b>Output:</b> 2
<p><strong>Example 2:</strong></p>

<b>Explanation:</b> You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2.
<pre>
<strong>Input:</strong> g = [1,2], s = [1,2,3]
<strong>Output:</strong> 2
<strong>Explanation:</strong> You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2.
You have 3 cookies and their sizes are big enough to gratify all of the children,
You need to output 2.
</pre>
</p>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= g.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>0 &lt;= s.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= g[i], s[j] &lt;=&nbsp;2<sup>31</sup> - 1</code></li>
</ul>

### Related Topics
[[Greedy](../../tag/greedy/README.md)]
76 changes: 35 additions & 41 deletions problems/asteroid-collision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,53 @@

## [735. Asteroid Collision (Medium)](https://leetcode.com/problems/asteroid-collision "行星碰撞")

<p>
We are given an array <code>asteroids</code> of integers representing asteroids in a row.
</p><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><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>

<p><b>Example 1:</b><br />
<p>We are given an array <code>asteroids</code> of integers representing asteroids in a row.</p>

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

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

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<b>Input:</b>
asteroids = [5, 10, -5]
<b>Output:</b> [5, 10]
<b>Explanation:</b>
The 10 and -5 collide resulting in 10. The 5 and 10 never collide.
<strong>Input:</strong> asteroids = [5,10,-5]
<strong>Output:</strong> [5,10]
<b>Explanation:</b> The 10 and -5 collide resulting in 10. The 5 and 10 never collide.
</pre>
</p>

<p><b>Example 2:</b><br />
<p><strong>Example 2:</strong></p>

<pre>
<b>Input:</b>
asteroids = [8, -8]
<b>Output:</b> []
<b>Explanation:</b>
The 8 and -8 collide exploding each other.
<strong>Input:</strong> asteroids = [8,-8]
<strong>Output:</strong> []
<b>Explanation:</b> The 8 and -8 collide exploding each other.
</pre>
</p>

<p><b>Example 3:</b><br />
<p><strong>Example 3:</strong></p>

<pre>
<b>Input:</b>
asteroids = [10, 2, -5]
<b>Output:</b> [10]
<b>Explanation:</b>
The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.
<strong>Input:</strong> asteroids = [10,2,-5]
<strong>Output:</strong> [10]
<b>Explanation:</b> The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.
</pre>
</p>

<p><b>Example 4:</b><br />
<p><strong>Example 4:</strong></p>

<pre>
<b>Input:</b>
asteroids = [-2, -1, 1, 2]
<b>Output:</b> [-2, -1, 1, 2]
<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.
<strong>Input:</strong> asteroids = [-2,-1,1,2]
<strong>Output:</strong> [-2,-1,1,2]
<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.
</pre>
</p>

<p><b>Note:</b>
<li>The length of <code>asteroids</code> will be at most <code>10000</code>.</li>
<li>Each asteroid will be a non-zero integer in the range <code>[-1000, 1000].</code>.</li>
</p>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= asteroids &lt;= 10<sup>4</sup></code></li>
<li><code>-1000 &lt;= asteroids[i] &lt;= 1000</code></li>
<li><code>asteroids[i] != 0</code></li>
</ul>

### Related Topics
[[Stack](../../tag/stack/README.md)]
Expand Down
2 changes: 1 addition & 1 deletion problems/bank-account-summary-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

[Next >](../sum-of-all-odd-length-subarrays "Sum of All Odd Length Subarrays")

## [1587. Bank Account Summary II (Easy)](https://leetcode.com/problems/bank-account-summary-ii "")
## [1587. Bank Account Summary II (Easy)](https://leetcode.com/problems/bank-account-summary-ii "银行账户概要 II")


Loading