Skip to content

Add: new #764

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

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <span id="1349">1349</span> | [Maximum Students Taking Exam](https://leetcode.com/problems/maximum-students-taking-exam "参加考试的最大学生数") | [Go](problems/maximum-students-taking-exam) | Hard |
| <span id="1348">1348</span> | [Tweet Counts Per Frequency](https://leetcode.com/problems/tweet-counts-per-frequency "推文计数") | [Go](problems/tweet-counts-per-frequency) | Medium |
| <span id="1347">1347</span> | [Minimum Number of Steps to Make Two Strings Anagram](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram "制造字母异位词的最小步骤数") | [Go](problems/minimum-number-of-steps-to-make-two-strings-anagram) | Medium |
| <span id="1346">1346</span> | [Check If N and Its Double Exist](https://leetcode.com/problems/check-if-n-and-its-double-exist "检查整数及其两倍数是否存在") | [Go](problems/check-if-n-and-its-double-exist) | Easy |
| <span id="1345">1345</span> | [Jump Game IV](https://leetcode.com/problems/jump-game-iv "跳跃游戏 IV") | [Go](problems/jump-game-iv) | Hard |
| <span id="1344">1344</span> | [Angle Between Hands of a Clock](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角") | [Go](problems/angle-between-hands-of-a-clock) | Medium |
| <span id="1343">1343</span> | [Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold](https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "大小为 K 且平均值大于等于阈值的子数组数目") | [Go](problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold) | Medium |
| <span id="1342">1342</span> | [Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero "将数字变成 0 的操作次数") | [Go](problems/number-of-steps-to-reduce-a-number-to-zero) | Easy |
| <span id="1341">1341</span> | [Movie Rating](https://leetcode.com/problems/movie-rating "电影评分") 🔒 | [MySQL](problems/movie-rating) | Medium |
| <span id="1340">1340</span> | [Jump Game V](https://leetcode.com/problems/jump-game-v "跳跃游戏 V") | [Go](problems/jump-game-v) | Hard |
| <span id="1339">1339</span> | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree "分裂二叉树的最大乘积") | [Go](problems/maximum-product-of-splitted-binary-tree) | Medium |
| <span id="1338">1338</span> | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half "数组大小减半") | [Go](problems/reduce-array-size-to-the-half) | Medium |
| <span id="1337">1337</span> | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix "方阵中战斗力最弱的 K 行") | [Go](problems/the-k-weakest-rows-in-a-matrix) | Easy |
| <span id="1336">1336</span> | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Medium |
| <span id="1336">1336</span> | [Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit) 🔒 | [MySQL](problems/number-of-transactions-per-visit) | Hard |
| <span id="1335">1335</span> | [Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule "工作计划的最低难度") | [Go](problems/minimum-difficulty-of-a-job-schedule) | Hard |
| <span id="1334">1334</span> | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance "阈值距离内邻居最少的城市") | [Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance) | Medium |
| <span id="1333">1333</span> | [Filter Restaurants by Vegan-Friendly, Price and Distance](https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance "餐厅过滤器") | [Go](problems/filter-restaurants-by-vegan-friendly-price-and-distance) | Medium |
Expand Down Expand Up @@ -191,14 +200,14 @@ LeetCode Problems' Solutions
| <span id="1214">1214</span> | [Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts "查找两棵二叉搜索树之和") 🔒 | [Go](problems/two-sum-bsts) | Medium |
| <span id="1213">1213</span> | [Intersection of Three Sorted Arrays](https://leetcode.com/problems/intersection-of-three-sorted-arrays "三个有序数组的交集") 🔒 | [Go](problems/intersection-of-three-sorted-arrays) | Easy |
| <span id="1212">1212</span> | [Team Scores in Football Tournament](https://leetcode.com/problems/team-scores-in-football-tournament "查询球队积分") 🔒 | [MySQL](problems/team-scores-in-football-tournament) | Medium |
| <span id="1211">1211</span> | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage) 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy |
| <span id="1211">1211</span> | [Queries Quality and Percentage](https://leetcode.com/problems/queries-quality-and-percentage "查询结果的质量和占比") 🔒 | [MySQL](problems/queries-quality-and-percentage) | Easy |
| <span id="1210">1210</span> | [Minimum Moves to Reach Target with Rotations](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations "穿过迷宫的最少移动次数") | [Go](problems/minimum-moves-to-reach-target-with-rotations) | Hard |
| <span id="1209">1209</span> | [Remove All Adjacent Duplicates in String II](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii "删除字符串中的所有相邻重复项 II") | [Go](problems/remove-all-adjacent-duplicates-in-string-ii) | Medium |
| <span id="1208">1208</span> | [Get Equal Substrings Within Budget](https://leetcode.com/problems/get-equal-substrings-within-budget "尽可能使字符串相等") | [Go](problems/get-equal-substrings-within-budget) | Medium |
| <span id="1207">1207</span> | [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences "独一无二的出现次数") | [Go](problems/unique-number-of-occurrences) | Easy |
| <span id="1206">1206</span> | [Design Skiplist](https://leetcode.com/problems/design-skiplist "设计跳表") | [Go](problems/design-skiplist) | Hard |
| <span id="1205">1205</span> | [Monthly Transactions II](https://leetcode.com/problems/monthly-transactions-ii "每月交易II") 🔒 | [MySQL](problems/monthly-transactions-ii) | Medium |
| <span id="1204">1204</span> | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator) 🔒 | [MySQL](problems/last-person-to-fit-in-the-elevator) | Medium |
| <span id="1204">1204</span> | [Last Person to Fit in the Elevator](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人") 🔒 | [MySQL](problems/last-person-to-fit-in-the-elevator) | Medium |
| <span id="1203">1203</span> | [Sort Items by Groups Respecting Dependencies](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies "项目管理") | [Go](problems/sort-items-by-groups-respecting-dependencies) | Hard |
| <span id="1202">1202</span> | [Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps "交换字符串中的元素") | [Go](problems/smallest-string-with-swaps) | Medium |
| <span id="1201">1201</span> | [Ugly Number III](https://leetcode.com/problems/ugly-number-iii "丑数 III") | [Go](problems/ugly-number-iii) | Medium |
Expand Down
79 changes: 79 additions & 0 deletions problems/angle-between-hands-of-a-clock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!--|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](../number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold")

[Next >](../jump-game-iv "Jump Game IV")

## [1344. Angle Between Hands of a Clock (Medium)](https://leetcode.com/problems/angle-between-hands-of-a-clock "时钟指针的夹角")

<p>Given two numbers, <code>hour</code> and <code>minutes</code>. Return the smaller angle (in sexagesimal units) formed between the <code>hour</code> and the <code>minute</code> hand.</p>

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

<p><img alt="" src="https://assets.leetcode.com/uploads/2019/12/26/sample_1_1673.png" style="width: 230px; height: 225px;" /></p>

<pre>
<strong>Input:</strong> hour = 12, minutes = 30
<strong>Output:</strong> 165
</pre>

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

<p><img alt="" src="https://assets.leetcode.com/uploads/2019/12/26/sample_2_1673.png" style="width: 230px; height: 225px;" /></p>

<pre>
<strong>Input:</strong> hour = 3, minutes = 30
<strong>Output:</strong> 75
</pre>

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

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/12/26/sample_3_1673.png" style="width: 230px; height: 225px;" /></strong></p>

<pre>
<strong>Input:</strong> hour = 3, minutes = 15
<strong>Output:</strong> 7.5
</pre>

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

<pre>
<strong>Input:</strong> hour = 4, minutes = 50
<strong>Output:</strong> 155
</pre>

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

<pre>
<strong>Input:</strong> hour = 12, minutes = 0
<strong>Output:</strong> 0
</pre>

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

<ul>
<li><code>1 &lt;= hour &lt;= 12</code></li>
<li><code>0 &lt;= minutes &lt;= 59</code></li>
<li>Answers within&nbsp;<code>10^-5</code>&nbsp;of the actual value will be accepted as correct.</li>
</ul>

### Related Topics
[[Math](../../tag/math/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
The tricky part is determining how the minute hand affects the position of the hour hand.
</details>

<details>
<summary>Hint 2</summary>
Calculate the angles separately then find the difference.
</details>
69 changes: 69 additions & 0 deletions problems/check-if-n-and-its-double-exist/README.md
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](../jump-game-iv "Jump Game IV")

[Next >](../minimum-number-of-steps-to-make-two-strings-anagram "Minimum Number of Steps to Make Two Strings Anagram")

## [1346. Check If N and Its Double Exist (Easy)](https://leetcode.com/problems/check-if-n-and-its-double-exist "检查整数及其两倍数是否存在")

<p>Given an array <code>arr</code> of integers, check if there exists two integers <code>N</code> and <code>M</code> such that <code>N</code> is the double of <code>M</code> ( i.e. <code>N = 2 * M</code>).</p>

<p>More formally check if there exists&nbsp;two indices <code>i</code> and <code>j</code> such that :</p>

<ul>
<li><code>i != j</code></li>
<li><code>0 &lt;= i, j &lt; arr.length</code></li>
<li><code>arr[i] == 2 * arr[j]</code></li>
</ul>

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

<pre>
<strong>Input:</strong> arr = [10,2,5,3]
<strong>Output:</strong> true
<strong>Explanation:</strong> N<code> = 10</code> is the double of M<code> = 5</code>,that is, <code>10 = 2 * 5</code>.
</pre>

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

<pre>
<strong>Input:</strong> arr = [7,1,14,11]
<strong>Output:</strong> true
<strong>Explanation:</strong> N<code> = 14</code> is the double of M<code> = 7</code>,that is, <code>14 = 2 * 7</code>.
</pre>

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

<pre>
<strong>Input:</strong> arr = [3,1,7,11]
<strong>Output:</strong> false
<strong>Explanation:</strong> In this case does not exist N and M, such that N = 2 * M.
</pre>

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

<ul>
<li><code>2 &lt;= arr.length &lt;= 500</code></li>
<li><code>-10^3 &lt;= arr[i] &lt;= 10^3</code></li>
</ul>

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

### Hints
<details>
<summary>Hint 1</summary>
Loop from i = 0 to arr.length, maintaining in a hashTable the array elements from [0, i - 1].
</details>

<details>
<summary>Hint 2</summary>
On each step of the loop check if we have seen the element 2 * arr[i] so far or arr[i] / 2 was seen if arr[i] % 2 == 0.
</details>
2 changes: 1 addition & 1 deletion problems/counting-bits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
</ul>

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

### Similar Questions
1. [Number of 1 Bits](../number-of-1-bits) (Easy)
Expand Down
2 changes: 1 addition & 1 deletion problems/intersection-of-two-arrays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
<p>&nbsp;</p>

### Related Topics
[[Sort](../../tag/sort/README.md)]
[[Hash Table](../../tag/hash-table/README.md)]
[[Two Pointers](../../tag/two-pointers/README.md)]
[[Binary Search](../../tag/binary-search/README.md)]
[[Sort](../../tag/sort/README.md)]

### Similar Questions
1. [Intersection of Two Arrays II](../intersection-of-two-arrays-ii) (Easy)
Expand Down
87 changes: 87 additions & 0 deletions problems/jump-game-iv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!--|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](../angle-between-hands-of-a-clock "Angle Between Hands of a Clock")

[Next >](../check-if-n-and-its-double-exist "Check If N and Its Double Exist")

## [1345. Jump Game IV (Hard)](https://leetcode.com/problems/jump-game-iv "跳跃游戏 IV")

<p>Given an array of&nbsp;integers <code>arr</code>, you are initially positioned at the first index of the array.</p>

<p>In one step you can jump from index <code>i</code> to index:</p>

<ul>
<li><code>i + 1</code> where:&nbsp;<code>i + 1 &lt; arr.length</code>.</li>
<li><code>i - 1</code> where:&nbsp;<code>i - 1 &gt;= 0</code>.</li>
<li><code>j</code> where: <code>arr[i] == arr[j]</code> and <code>i != j</code>.</li>
</ul>

<p>Return <em>the minimum number of steps</em> to reach the <strong>last index</strong> of the array.</p>

<p>Notice that you can not jump outside of the array at any time.</p>

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

<pre>
<strong>Input:</strong> arr = [100,-23,-23,404,100,23,23,23,3,404]
<strong>Output:</strong> 3
<strong>Explanation:</strong> You need three jumps from index 0 --&gt; 4 --&gt; 3 --&gt; 9. Note that index 9 is the last index of the array.
</pre>

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

<pre>
<strong>Input:</strong> arr = [7]
<strong>Output:</strong> 0
<strong>Explanation:</strong> Start index is the last index. You don&#39;t need to jump.
</pre>

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

<pre>
<strong>Input:</strong> arr = [7,6,9,6,9,6,9,7]
<strong>Output:</strong> 1
<strong>Explanation:</strong> You can jump directly from index 0 to index 7 which is last index of the array.
</pre>

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

<pre>
<strong>Input:</strong> arr = [6,1,9]
<strong>Output:</strong> 2
</pre>

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

<pre>
<strong>Input:</strong> arr = [11,22,7,7,7,7,7,7,7,22,13]
<strong>Output:</strong> 3
</pre>

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

<ul>
<li><code>1 &lt;= arr.length &lt;= 5 * 10^4</code></li>
<li><code>-10^8 &lt;= arr[i] &lt;= 10^8</code></li>
</ul>

### Related Topics
[[Breadth-first Search](../../tag/breadth-first-search/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j].
</details>

<details>
<summary>Hint 2</summary>
Start bfs from node 0 and keep distance, answer is the distance when you reach onode n-1.
</details>
2 changes: 1 addition & 1 deletion problems/jump-game-v/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[< Previous](../maximum-product-of-splitted-binary-tree "Maximum Product of Splitted Binary Tree")

Next >
[Next >](../movie-rating "Movie Rating")

## [1340. Jump Game V (Hard)](https://leetcode.com/problems/jump-game-v "跳跃游戏 V")

Expand Down
2 changes: 1 addition & 1 deletion problems/last-person-to-fit-in-the-elevator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

[Next >](../monthly-transactions-ii "Monthly Transactions II")

## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "")
## [1204. Last Person to Fit in the Elevator (Medium)](https://leetcode.com/problems/last-person-to-fit-in-the-elevator "最后一个能进入电梯的人")

<p>Table: <code>Queue</code></p>

Expand Down
Loading