Skip to content

A: new #789

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
May 18, 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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <span id="1453">1453</span> | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard |
| <span id="1452">1452</span> | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium |
| <span id="1451">1451</span> | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium |
| <span id="1450">1450</span> | [Number of Students Doing Homework at a Given Time](https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time "在既定时间做作业的学生人数") | [Go](problems/number-of-students-doing-homework-at-a-given-time) | Easy |
| <span id="1449">1449</span> | [Form Largest Integer With Digits That Add up to Target](https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target "数位成本和为目标值的最大数字") | [Go](problems/form-largest-integer-with-digits-that-add-up-to-target) | Hard |
| <span id="1448">1448</span> | [Count Good Nodes in Binary Tree](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目") | [Go](problems/count-good-nodes-in-binary-tree) | Medium |
| <span id="1447">1447</span> | [Simplified Fractions](https://leetcode.com/problems/simplified-fractions "最简分数") | [Go](problems/simplified-fractions) | Medium |
| <span id="1446">1446</span> | [Consecutive Characters](https://leetcode.com/problems/consecutive-characters "连续字符") | [Go](problems/consecutive-characters) | Easy |
| <span id="1445">1445</span> | [Apples & Oranges](https://leetcode.com/problems/apples-oranges) 🔒 | [MySQL](problems/apples-oranges) | Medium |
| <span id="1444">1444</span> | [Number of Ways of Cutting a Pizza](https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza "切披萨的方案数") | [Go](problems/number-of-ways-of-cutting-a-pizza) | Hard |
| <span id="1443">1443</span> | [Minimum Time to Collect All Apples in a Tree](https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree "收集树上所有苹果的最少时间") | [Go](problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium |
| <span id="1442">1442</span> | [Count Triplets That Can Form Two Arrays of Equal XOR](https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor "形成两个异或相等数组的三元组数目") | [Go](problems/count-triplets-that-can-form-two-arrays-of-equal-xor) | Medium |
Expand All @@ -85,7 +94,7 @@ LeetCode Problems' Solutions
| <span id="1424">1424</span> | [Diagonal Traverse II](https://leetcode.com/problems/diagonal-traverse-ii "对角线遍历 II") | [Go](problems/diagonal-traverse-ii) | Medium |
| <span id="1423">1423</span> | [Maximum Points You Can Obtain from Cards](https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards "可获得的最大点数") | [Go](problems/maximum-points-you-can-obtain-from-cards) | Medium |
| <span id="1422">1422</span> | [Maximum Score After Splitting a String](https://leetcode.com/problems/maximum-score-after-splitting-a-string "分割字符串的最大得分") | [Go](problems/maximum-score-after-splitting-a-string) | Easy |
| <span id="1421">1421</span> | [NPV Queries](https://leetcode.com/problems/npv-queries) 🔒 | [MySQL](problems/npv-queries) | Medium |
| <span id="1421">1421</span> | [NPV Queries](https://leetcode.com/problems/npv-queries "净现值查询") 🔒 | [MySQL](problems/npv-queries) | Medium |
| <span id="1420">1420</span> | [Build Array Where You Can Find The Maximum Exactly K Comparisons](https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons "生成数组") | [Go](problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons) | Hard |
| <span id="1419">1419</span> | [Minimum Number of Frogs Croaking](https://leetcode.com/problems/minimum-number-of-frogs-croaking "数青蛙") | [Go](problems/minimum-number-of-frogs-croaking) | Medium |
| <span id="1418">1418</span> | [Display Table of Food Orders in a Restaurant](https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant "点菜展示表") | [Go](problems/display-table-of-food-orders-in-a-restaurant) | Medium |
Expand All @@ -94,7 +103,7 @@ LeetCode Problems' Solutions
| <span id="1415">1415</span> | [The k-th Lexicographical String of All Happy Strings of Length n](https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n "长度为 n 的开心字符串中字典序第 k 小的字符串") | [Go](problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n) | Medium |
| <span id="1414">1414</span> | [Find the Minimum Number of Fibonacci Numbers Whose Sum Is K](https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k "和为 K 的最少斐波那契数字数目") | [Go](problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k) | Medium |
| <span id="1413">1413</span> | [Minimum Value to Get Positive Step by Step Sum](https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum "逐步求和得到正数的最小值") | [Go](problems/minimum-value-to-get-positive-step-by-step-sum) | Easy |
| <span id="1412">1412</span> | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams) 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard |
| <span id="1412">1412</span> | [Find the Quiet Students in All Exams](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生") 🔒 | [MySQL](problems/find-the-quiet-students-in-all-exams) | Hard |
| <span id="1411">1411</span> | [Number of Ways to Paint N × 3 Grid](https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid "给 N x 3 网格图涂色的方案数") | [Go](problems/number-of-ways-to-paint-n-3-grid) | Hard |
| <span id="1410">1410</span> | [HTML Entity Parser](https://leetcode.com/problems/html-entity-parser "HTML 实体解析器") | [Go](problems/html-entity-parser) | Medium |
| <span id="1409">1409</span> | [Queries on a Permutation With Key](https://leetcode.com/problems/queries-on-a-permutation-with-key "查询带键的排列") | [Go](problems/queries-on-a-permutation-with-key) | Medium |
Expand Down
14 changes: 14 additions & 0 deletions problems/apples-oranges/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](../number-of-ways-of-cutting-a-pizza "Number of Ways of Cutting a Pizza")

[Next >](../consecutive-characters "Consecutive Characters")

## [1445. Apples & Oranges (Medium)](https://leetcode.com/problems/apples-oranges "")


10 changes: 10 additions & 0 deletions problems/apples-oranges/mysql_schemas.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Create table If Not Exists Sales (sale_date date, fruit ENUM('apples', 'oranges'), sold_num int);
Truncate table Sales;
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-01', 'apples', '10');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-01', 'oranges', '8');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-02', 'apples', '15');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-02', 'oranges', '15');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-03', 'apples', '20');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-03', 'oranges', '0');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-04', 'apples', '15');
insert into Sales (sale_date, fruit, sold_num) values ('2020-05-04', 'oranges', '16');
76 changes: 76 additions & 0 deletions problems/consecutive-characters/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](../apples-oranges "Apples & Oranges")

[Next >](../simplified-fractions "Simplified Fractions")

## [1446. Consecutive Characters (Easy)](https://leetcode.com/problems/consecutive-characters "连续字符")

<p>Given a string <code>s</code>, the power of the string is the maximum length of a non-empty substring that&nbsp;contains only one unique character.</p>

<p>Return <em>the power</em>&nbsp;of the string.</p>

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

<pre>
<strong>Input:</strong> s = &quot;leetcode&quot;
<strong>Output:</strong> 2
<strong>Explanation:</strong> The substring &quot;ee&quot; is of length 2 with the character &#39;e&#39; only.
</pre>

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

<pre>
<strong>Input:</strong> s = &quot;abbcccddddeeeeedcba&quot;
<strong>Output:</strong> 5
<strong>Explanation:</strong> The substring &quot;eeeee&quot; is of length 5 with the character &#39;e&#39; only.
</pre>

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

<pre>
<strong>Input:</strong> s = &quot;triplepillooooow&quot;
<strong>Output:</strong> 5
</pre>

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

<pre>
<strong>Input:</strong> s = &quot;hooraaaaaaaaaaay&quot;
<strong>Output:</strong> 11
</pre>

<p><strong>Example 5:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;tourist&quot;
<strong>Output:</strong> 1
</pre>

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

<ul>
<li><code>1 &lt;= s.length &lt;= 500</code></li>
<li><code>s</code> contains only lowercase English letters.</li>
</ul>

### Related Topics
[[String](../../tag/string/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Keep an array power where power[i] is the maximum power of the i-th character.
</details>

<details>
<summary>Hint 2</summary>
The answer is max(power[i]).
</details>
64 changes: 64 additions & 0 deletions problems/count-good-nodes-in-binary-tree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](../simplified-fractions "Simplified Fractions")

[Next >](../form-largest-integer-with-digits-that-add-up-to-target "Form Largest Integer With Digits That Add up to Target")

## [1448. Count Good Nodes in Binary Tree (Medium)](https://leetcode.com/problems/count-good-nodes-in-binary-tree "统计二叉树中好节点的数目")

<p>Given a binary tree <code>root</code>, a node <em>X</em> in the tree is named&nbsp;<strong>good</strong> if in the path from root to <em>X</em> there are no nodes with a value <em>greater than</em> X.</p>

<p>Return the number of <strong>good</strong> nodes in the binary tree.</p>

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

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/04/02/test_sample_1.png" style="width: 263px; height: 156px;" /></strong></p>

<pre>
<strong>Input:</strong> root = [3,1,4,3,null,1,5]
<strong>Output:</strong> 4
<strong>Explanation:</strong> Nodes in blue are <strong>good</strong>.
Root Node (3) is always a good node.
Node 4 -&gt; (3,4) is the maximum value in the path starting from the root.
Node 5 -&gt; (3,4,5) is the maximum value in the path
Node 3 -&gt; (3,1,3) is the maximum value in the path.</pre>

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

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/04/02/test_sample_2.png" style="width: 157px; height: 161px;" /></strong></p>

<pre>
<strong>Input:</strong> root = [3,3,null,4,2]
<strong>Output:</strong> 3
<strong>Explanation:</strong> Node 2 -&gt; (3, 3, 2) is not good, because &quot;3&quot; is higher than it.</pre>

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

<pre>
<strong>Input:</strong> root = [1]
<strong>Output:</strong> 1
<strong>Explanation:</strong> Root is considered as <strong>good</strong>.</pre>

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

<ul>
<li>The number of nodes in the binary tree is in the range&nbsp;<code>[1, 10^5]</code>.</li>
<li>Each node&#39;s value is between <code>[-10^4, 10^4]</code>.</li>
</ul>

### Related Topics
[[Tree](../../tag/tree/README.md)]
[[Depth-first Search](../../tag/depth-first-search/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Use DFS (Depth First Search) to traverse the tree, and constantly keep track of the current path maximum.
</details>
18 changes: 6 additions & 12 deletions problems/cousins-in-binary-tree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,18 @@

<pre>
<strong>Input: </strong>root = <span id="example-input-3-1">[1,2,3,null,4]</span>, x = 2, y = 3
<strong>Output: </strong><span id="example-output-3">false</span></pre>

<p>&nbsp;</p>
<strong>Output: </strong><span id="example-output-3">false</span>
</pre>
</div>
</div>

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

<ol>
<ul>
<li>The number of nodes in the tree will be between <code>2</code> and <code>100</code>.</li>
<li>Each node has a unique integer value from <code>1</code> to <code>100</code>.</li>
</ol>

<div>
<div>
<div>&nbsp;</div>
</div>
</div>
</ul>

### Related Topics
[[Tree](../../tag/tree/README.md)]
Expand Down
2 changes: 1 addition & 1 deletion problems/find-the-quiet-students-in-all-exams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

[Next >](../minimum-value-to-get-positive-step-by-step-sum "Minimum Value to Get Positive Step by Step Sum")

## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "")
## [1412. Find the Quiet Students in All Exams (Hard)](https://leetcode.com/problems/find-the-quiet-students-in-all-exams "查找成绩处于中游的的学生")


65 changes: 19 additions & 46 deletions problems/find-the-town-judge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,33 @@
<p>If the town judge exists and can be identified, return the label of the town judge.&nbsp; Otherwise, return <code>-1</code>.</p>

<p>&nbsp;</p>

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

<pre>
<strong>Input: </strong>N = <span id="example-input-1-1">2</span>, trust = <span id="example-input-1-2">[[1,2]]</span>
<strong>Output: </strong><span id="example-output-1">2</span>
</pre>

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

<pre>
<strong>Input: </strong>N = <span id="example-input-2-1">3</span>, trust = <span id="example-input-2-2">[[1,3],[2,3]]</span>
<strong>Output: </strong><span id="example-output-2">3</span>
<pre><strong>Input:</strong> N = 2, trust = [[1,2]]
<strong>Output:</strong> 2
</pre><p><strong>Example 2:</strong></p>
<pre><strong>Input:</strong> N = 3, trust = [[1,3],[2,3]]
<strong>Output:</strong> 3
</pre><p><strong>Example 3:</strong></p>
<pre><strong>Input:</strong> N = 3, trust = [[1,3],[2,3],[3,1]]
<strong>Output:</strong> -1
</pre><p><strong>Example 4:</strong></p>
<pre><strong>Input:</strong> N = 3, trust = [[1,2],[2,3]]
<strong>Output:</strong> -1
</pre><p><strong>Example 5:</strong></p>
<pre><strong>Input:</strong> N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]]
<strong>Output:</strong> 3
</pre>

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

<pre>
<strong>Input: </strong>N = <span id="example-input-3-1">3</span>, trust = <span id="example-input-3-2">[[1,3],[2,3],[3,1]]</span>
<strong>Output: </strong><span id="example-output-3">-1</span>
</pre>

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

<pre>
<strong>Input: </strong>N = <span id="example-input-4-1">3</span>, trust = <span id="example-input-4-2">[[1,2],[2,3]]</span>
<strong>Output: </strong><span id="example-output-4">-1</span>
</pre>

<div>
<p><strong>Example 5:</strong></p>

<pre>
<strong>Input: </strong>N = <span id="example-input-5-1">4</span>, trust = <span id="example-input-5-2">[[1,3],[1,4],[2,3],[2,4],[4,3]]</span>
<strong>Output: </strong><span id="example-output-5">3</span></pre>

<p>&nbsp;</p>
</div>
</div>
</div>
</div>

<p><strong>Note:</strong></p>
<p><strong>Constraints:</strong></p>

<ol>
<ul>
<li><code>1 &lt;= N &lt;= 1000</code></li>
<li><code>trust.length &lt;= 10000</code></li>
<li><code>0 &lt;= trust.length &lt;= 10^4</code></li>
<li><code>trust[i].length == 2</code></li>
<li><code>trust[i]</code> are all different</li>
<li><code>trust[i][0] != trust[i][1]</code></li>
<li><code>1 &lt;= trust[i][0], trust[i][1] &lt;= N</code></li>
</ol>
</ul>

### Related Topics
[[Graph](../../tag/graph/README.md)]
Expand Down
Loading