Skip to content

A: new #798

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 1 commit into from
Jun 28, 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
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,23 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <span id="1495">1495</span> | [Friendly Movies Streamed Last Month](https://leetcode.com/problems/friendly-movies-streamed-last-month) 🔒 | [MySQL](problems/friendly-movies-streamed-last-month) | Easy |
| <span id="1494">1494</span> | [Parallel Courses II](https://leetcode.com/problems/parallel-courses-ii "并行课程 II") | [Go](problems/parallel-courses-ii) | Hard |
| <span id="1493">1493</span> | [Longest Subarray of 1's After Deleting One Element](https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element "删掉一个元素以后全为 1 的最长子数组") | [Go](problems/longest-subarray-of-1s-after-deleting-one-element) | Medium |
| <span id="1492">1492</span> | [The kth Factor of n](https://leetcode.com/problems/the-kth-factor-of-n "n 的第 k 个因子") | [Go](problems/the-kth-factor-of-n) | Medium |
| <span id="1491">1491</span> | [Average Salary Excluding the Minimum and Maximum Salary](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值") | [Go](problems/average-salary-excluding-the-minimum-and-maximum-salary) | Easy |
| <span id="1490">1490</span> | [Clone N-ary Tree](https://leetcode.com/problems/clone-n-ary-tree "克隆 N 叉树") 🔒 | [Go](problems/clone-n-ary-tree) | Medium |
| <span id="1489">1489</span> | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边") | [Go](problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | Hard |
| <span id="1488">1488</span> | [Avoid Flood in The City](https://leetcode.com/problems/avoid-flood-in-the-city "避免洪水泛滥") | [Go](problems/avoid-flood-in-the-city) | Medium |
| <span id="1487">1487</span> | [Making File Names Unique](https://leetcode.com/problems/making-file-names-unique "保证文件名唯一") | [Go](problems/making-file-names-unique) | Medium |
| <span id="1486">1486</span> | [XOR Operation in an Array](https://leetcode.com/problems/xor-operation-in-an-array "数组异或操作") | [Go](problems/xor-operation-in-an-array) | Easy |
| <span id="1485">1485</span> | [Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer "克隆含随机指针的二叉树") 🔒 | [Go](problems/clone-binary-tree-with-random-pointer) | Medium |
| <span id="1484">1484</span> | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date) 🔒 | [MySQL](problems/group-sold-products-by-the-date) | Easy |
| <span id="1484">1484</span> | [Group Sold Products By The Date](https://leetcode.com/problems/group-sold-products-by-the-date "按日期分组销售产品") 🔒 | [MySQL](problems/group-sold-products-by-the-date) | Easy |
| <span id="1483">1483</span> | [Kth Ancestor of a Tree Node](https://leetcode.com/problems/kth-ancestor-of-a-tree-node "树节点的第 K 个祖先") | [Go](problems/kth-ancestor-of-a-tree-node) | Hard |
| <span id="1482">1482</span> | [Minimum Number of Days to Make m Bouquets](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets "制作 m 束花所需的最少天数") | [Go](problems/minimum-number-of-days-to-make-m-bouquets) | Medium |
| <span id="1481">1481</span> | [Least Number of Unique Integers after K Removals](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals "不同整数的最少数目") | [Go](problems/least-number-of-unique-integers-after-k-removals) | Medium |
| <span id="1480">1480</span> | [Running Sum of 1d Array](https://leetcode.com/problems/running-sum-of-1d-array "一维数组的动态和") | [Go](problems/running-sum-of-1d-array) | Easy |
| <span id="1479">1479</span> | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week) 🔒 | [MySQL](problems/sales-by-day-of-the-week) | Hard |
| <span id="1479">1479</span> | [Sales by Day of the Week](https://leetcode.com/problems/sales-by-day-of-the-week "周内每天的销售情况") 🔒 | [MySQL](problems/sales-by-day-of-the-week) | Hard |
| <span id="1478">1478</span> | [Allocate Mailboxes](https://leetcode.com/problems/allocate-mailboxes "安排邮筒") | [Go](problems/allocate-mailboxes) | Hard |
| <span id="1477">1477</span> | [Find Two Non-overlapping Sub-arrays Each With Target Sum](https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum "找两个和为目标值且不重叠的子数组") | [Go](problems/find-two-non-overlapping-sub-arrays-each-with-target-sum) | Medium |
| <span id="1476">1476</span> | [Subrectangle Queries](https://leetcode.com/problems/subrectangle-queries "子矩形查询") | [Go](problems/subrectangle-queries) | Medium |
Expand All @@ -82,7 +88,7 @@ LeetCode Problems' Solutions
| <span id="1472">1472</span> | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium |
| <span id="1471">1471</span> | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium |
| <span id="1470">1470</span> | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy |
| <span id="1469">1469</span> | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes) 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy |
| <span id="1469">1469</span> | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes "寻找所有的独生节点") 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy |
| <span id="1468">1468</span> | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries "计算税后工资") 🔒 | [MySQL](problems/calculate-salaries) | Medium |
| <span id="1467">1467</span> | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard |
| <span id="1466">1466</span> | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium |
Expand Down Expand Up @@ -116,13 +122,13 @@ LeetCode Problems' Solutions
| <span id="1438">1438</span> | [Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit](https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit "绝对差不超过限制的最长连续子数组") | [Go](problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit) | Medium |
| <span id="1437">1437</span> | [Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away "是否所有 1 都至少相隔 k 个元素") | [Go](problems/check-if-all-1s-are-at-least-length-k-places-away) | Medium |
| <span id="1436">1436</span> | [Destination City](https://leetcode.com/problems/destination-city "旅行终点站") | [Go](problems/destination-city) | Easy |
| <span id="1435">1435</span> | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart) 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy |
| <span id="1435">1435</span> | [Create a Session Bar Chart](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图") 🔒 | [MySQL](problems/create-a-session-bar-chart) | Easy |
| <span id="1434">1434</span> | [Number of Ways to Wear Different Hats to Each Other](https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other "每个人戴不同帽子的方案数") | [Go](problems/number-of-ways-to-wear-different-hats-to-each-other) | Hard |
| <span id="1433">1433</span> | [Check If a String Can Break Another String](https://leetcode.com/problems/check-if-a-string-can-break-another-string "检查一个字符串是否可以打破另一个字符串") | [Go](problems/check-if-a-string-can-break-another-string) | Medium |
| <span id="1432">1432</span> | [Max Difference You Can Get From Changing an Integer](https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer "改变一个整数能得到的最大差值") | [Go](problems/max-difference-you-can-get-from-changing-an-integer) | Medium |
| <span id="1431">1431</span> | [Kids With the Greatest Number of Candies](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies "拥有最多糖果的孩子") | [Go](problems/kids-with-the-greatest-number-of-candies) | Easy |
| <span id="1430">1430</span> | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium |
| <span id="1429">1429</span> | [First Unique Number](https://leetcode.com/problems/first-unique-number) 🔒 | [Go](problems/first-unique-number) | Medium |
| <span id="1430">1430</span> | [Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "判断给定的序列是否是二叉树从根到叶的路径") 🔒 | [Go](problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree) | Medium |
| <span id="1429">1429</span> | [First Unique Number](https://leetcode.com/problems/first-unique-number "第一个唯一数字") 🔒 | [Go](problems/first-unique-number) | Medium |
| <span id="1428">1428</span> | [Leftmost Column with at Least a One](https://leetcode.com/problems/leftmost-column-with-at-least-a-one "至少有一个 1 的最左端列") 🔒 | [Go](problems/leftmost-column-with-at-least-a-one) | Medium |
| <span id="1427">1427</span> | [Perform String Shifts](https://leetcode.com/problems/perform-string-shifts "字符串的左右移") 🔒 | [Go](problems/perform-string-shifts) | Easy |
| <span id="1426">1426</span> | [Counting Elements](https://leetcode.com/problems/counting-elements "数元素") 🔒 | [Go](problems/counting-elements) | Easy |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](../clone-n-ary-tree "Clone N-ary Tree")

[Next >](../the-kth-factor-of-n "The kth Factor of n")

## [1491. Average Salary Excluding the Minimum and Maximum Salary (Easy)](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary "去掉最低工资和最高工资后的工资平均值")

<p>Given an array of <strong>unique</strong> integers <code>salary</code>&nbsp;where <code>salary[i]</code> is the salary of the employee <code>i</code>.</p>

<p>Return the average salary of employees excluding the minimum and maximum salary.</p>

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

<pre>
<strong>Input:</strong> salary = [4000,3000,1000,2000]
<strong>Output:</strong> 2500.00000
<strong>Explanation: </strong>Minimum salary and maximum salary are 1000 and 4000 respectively.
Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500
</pre>

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

<pre>
<strong>Input:</strong> salary = [1000,2000,3000]
<strong>Output:</strong> 2000.00000
<strong>Explanation: </strong>Minimum salary and maximum salary are 1000 and 3000 respectively.
Average salary excluding minimum and maximum salary is (2000)/1= 2000
</pre>

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

<pre>
<strong>Input:</strong> salary = [6000,5000,4000,3000,2000,1000]
<strong>Output:</strong> 3500.00000
</pre>

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

<pre>
<strong>Input:</strong> salary = [8000,9000,2000,3000,6000,1000]
<strong>Output:</strong> 4750.00000
</pre>

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

<ul>
<li><code>3 &lt;= salary.length &lt;= 100</code></li>
<li><code>10^3&nbsp;&lt;= salary[i] &lt;= 10^6</code></li>
<li><code>salary[i]</code> is unique.</li>
<li>Answers within <code>10^-5</code> of the actual value will be accepted as correct.</li>
</ul>

### Related Topics
[[Sort](../../tag/sort/README.md)]
[[Array](../../tag/array/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Get the total sum and subtract the minimum and maximum value in the array. Finally divide the result by n - 2.
</details>
17 changes: 8 additions & 9 deletions problems/buddy-strings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,20 @@
<strong>Input: </strong>A = <span id="example-input-5-1">&quot;&quot;</span>, B = <span id="example-input-5-2">&quot;aa&quot;</span>
<strong>Output: </strong><span id="example-output-5">false</span>
</pre>
</div>
</div>
</div>
</div>
</div>

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

<p><strong><span>Note:</span></strong></p>

<ol>
<ul>
<li><code>0 &lt;= A.length &lt;= 20000</code></li>
<li><code>0 &lt;= B.length &lt;= 20000</code></li>
<li><code>A</code> and&nbsp;<code>B</code> consist only of lowercase letters.</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</ul>

### Related Topics
[[String](../../tag/string/README.md)]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

[Next >](../kids-with-the-greatest-number-of-candies "Kids With the Greatest Number of Candies")

## [1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree (Medium)](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "")
## [1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree (Medium)](https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "判断给定的序列是否是二叉树从根到叶的路径")



Expand Down
9 changes: 7 additions & 2 deletions problems/climbing-stairs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

<p>Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?</p>

<p><strong>Note:</strong> Given <em>n</em> will be a positive integer.</p>

<p><strong>Example 1:</strong></p>

<pre>
Expand All @@ -38,6 +36,13 @@
3. 2 steps + 1 step
</pre>

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

<ul>
<li><code>1 &lt;= n &lt;= 45</code></li>
</ul>

### Related Topics
[[Dynamic Programming](../../tag/dynamic-programming/README.md)]

Expand Down
31 changes: 31 additions & 0 deletions problems/clone-n-ary-tree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](../find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree")

[Next >](../average-salary-excluding-the-minimum-and-maximum-salary "Average Salary Excluding the Minimum and Maximum Salary")

## [1490. Clone N-ary Tree (Medium)](https://leetcode.com/problems/clone-n-ary-tree "克隆 N 叉树")



### Related Topics
[[Tree](../../tag/tree/README.md)]
[[Depth-first Search](../../tag/depth-first-search/README.md)]
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Traverse the tree, keep a hashtable with you and create a clone node for each node in the tree.
</details>

<details>
<summary>Hint 2</summary>
Start traversing the original tree again and connect each child pointer in the cloned tree the same way as the original tree with the help of the hashtable.
</details>
2 changes: 1 addition & 1 deletion problems/create-a-session-bar-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

[Next >](../destination-city "Destination City")

## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "")
## [1435. Create a Session Bar Chart (Easy)](https://leetcode.com/problems/create-a-session-bar-chart "制作会话柱状图")


8 changes: 8 additions & 0 deletions problems/excel-sheet-column-number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
<strong>Input: </strong>&quot;ZY&quot;
<strong>Output:</strong> 701
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= s.length &lt;= 7</code></li>
<li><code>s</code> consists only of uppercase English letters.</li>
<li><code>s</code> is between &quot;A&quot; and &quot;FXSHRXW&quot;.</li>
</ul>

### Related Topics
[[Math](../../tag/math/README.md)]
Expand Down
2 changes: 1 addition & 1 deletion problems/find-all-the-lonely-nodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

[Next >](../shuffle-the-array "Shuffle the Array")

## [1469. Find All The Lonely Nodes (Easy)](https://leetcode.com/problems/find-all-the-lonely-nodes "")
## [1469. Find All The Lonely Nodes (Easy)](https://leetcode.com/problems/find-all-the-lonely-nodes "寻找所有的独生节点")



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[< Previous](../avoid-flood-in-the-city "Avoid Flood in The City")

Next >
[Next >](../clone-n-ary-tree "Clone N-ary Tree")

## [1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree (Hard)](https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree "找到最小生成树里的关键边和伪关键边")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
<strong>Input:</strong> nums = [<code>5,7,7,8,8,10]</code>, target = 6
<strong>Output:</strong> [-1,-1]</pre>

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

<ul>
<li><code>0 &lt;= nums.length &lt;= 10^5</code></li>
<li><code>-10^9&nbsp;&lt;= nums[i]&nbsp;&lt;= 10^9</code></li>
<li><code>nums</code> is a non decreasing array.</li>
<li><code>-10^9&nbsp;&lt;= target&nbsp;&lt;= 10^9</code></li>
</ul>

### Related Topics
[[Array](../../tag/array/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
Expand Down
6 changes: 3 additions & 3 deletions problems/first-unique-character-in-a-string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

## [387. First Unique Character in a String (Easy)](https://leetcode.com/problems/first-unique-character-in-a-string "字符串中的第一个唯一字符")

<p>Given a string, find the first non-repeating character in it and return it&#39;s index. If it doesn&#39;t exist, return -1.</p>
<p>Given a string, find the first non-repeating character in it and return its index. If it doesn&#39;t exist, return -1.</p>

<p><b>Examples:</b></p>

<pre>
s = &quot;leetcode&quot;
return 0.

s = &quot;loveleetcode&quot;,
s = &quot;loveleetcode&quot;
return 2.
</pre>

<p>&nbsp;</p>

<p><b>Note:</b> You may assume the string contain only lowercase English letters.</p>
<p><b>Note:</b> You may assume the string contains only lowercase English letters.</p>

### Related Topics
[[Hash Table](../../tag/hash-table/README.md)]
Expand Down
2 changes: 1 addition & 1 deletion problems/first-unique-number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

[Next >](../check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree")

## [1429. First Unique Number (Medium)](https://leetcode.com/problems/first-unique-number "")
## [1429. First Unique Number (Medium)](https://leetcode.com/problems/first-unique-number "第一个唯一数字")



Expand Down
Loading