Skip to content

Add: new #717

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
Nov 25, 2019
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
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <span id="1269">1269</span> | [Number of Ways to Stay in the Same Place After Some Steps](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps) | Hard |
| <span id="1268">1268</span> | [Search Suggestions System](https://leetcode.com/problems/search-suggestions-system "搜索推荐系统") | [Go](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system) | Medium |
| <span id="1267">1267</span> | [Count Servers that Communicate](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器") | [Go](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate) | Medium |
| <span id="1266">1266</span> | [Minimum Time Visiting All Points](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points) | Easy |
| <span id="1265">1265</span> | [Print Immutable Linked List in Reverse](https://leetcode.com/problems/print-immutable-linked-list-in-reverse) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/print-immutable-linked-list-in-reverse) | Medium |
| <span id="1264">1264</span> | [Page Recommendations](https://leetcode.com/problems/page-recommendations) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/page-recommendations) | Medium |
| <span id="1263">1263</span> | [Minimum Moves to Move a Box to Their Target Location](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-moves-to-move-a-box-to-their-target-location) | Hard |
| <span id="1262">1262</span> | [Greatest Sum Divisible by Three](https://leetcode.com/problems/greatest-sum-divisible-by-three "可被三整除的最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/greatest-sum-divisible-by-three) | Medium |
| <span id="1261">1261</span> | [Find Elements in a Contaminated Binary Tree](https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree "在受污染的二叉树中查找元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-elements-in-a-contaminated-binary-tree) | Medium |
| <span id="1260">1260</span> | [Shift 2D Grid](https://leetcode.com/problems/shift-2d-grid "二维网格迁移") | [Go](https://github.com/openset/leetcode/tree/master/problems/shift-2d-grid) | Easy |
| <span id="1259">1259</span> | [Handshakes That Don't Cross](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") | [Go](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross) | Hard |
| <span id="1258">1258</span> | [Synonymous Sentences](https://leetcode.com/problems/synonymous-sentences "近义词句子") | [Go](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences) | Medium |
| <span id="1257">1257</span> | [Smallest Common Region](https://leetcode.com/problems/smallest-common-region "最小公共区域") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region) | Medium |
| <span id="1256">1256</span> | [Encode Number](https://leetcode.com/problems/encode-number "加密数字") | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-number) | Medium |
| <span id="1259">1259</span> | [Handshakes That Don't Cross](https://leetcode.com/problems/handshakes-that-dont-cross "不相交的握手") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/handshakes-that-dont-cross) | Hard |
| <span id="1258">1258</span> | [Synonymous Sentences](https://leetcode.com/problems/synonymous-sentences "近义词句子") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/synonymous-sentences) | Medium |
| <span id="1257">1257</span> | [Smallest Common Region](https://leetcode.com/problems/smallest-common-region "最小公共区域") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-common-region) | Medium |
| <span id="1256">1256</span> | [Encode Number](https://leetcode.com/problems/encode-number "加密数字") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/encode-number) | Medium |
| <span id="1255">1255</span> | [Maximum Score Words Formed by Letters](https://leetcode.com/problems/maximum-score-words-formed-by-letters "得分最高的单词集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-score-words-formed-by-letters) | Hard |
| <span id="1254">1254</span> | [Number of Closed Islands](https://leetcode.com/problems/number-of-closed-islands "统计封闭岛屿的数目") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-closed-islands) | Medium |
| <span id="1253">1253</span> | [Reconstruct a 2-Row Binary Matrix](https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix "重构 2 行二进制矩阵") | [Go](https://github.com/openset/leetcode/tree/master/problems/reconstruct-a-2-row-binary-matrix) | Medium |
Expand Down Expand Up @@ -183,7 +189,7 @@ LeetCode Problems' Solutions
| <span id="1145">1145</span> | [Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game "二叉树着色游戏") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-coloring-game) | Medium |
| <span id="1144">1144</span> | [Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag "递减元素使数组呈锯齿状") | [Go](https://github.com/openset/leetcode/tree/master/problems/decrease-elements-to-make-array-zigzag) | Medium |
| <span id="1143">1143</span> | [Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence "最长公共子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-common-subsequence) | Medium |
| <span id="1142">1142</span> | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-ii) | Easy |
| <span id="1142">1142</span> | [User Activity for the Past 30 Days II](https://leetcode.com/problems/user-activity-for-the-past-30-days-ii "过去30天的用户活动 II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-ii) | Easy |
| <span id="1141">1141</span> | [User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/user-activity-for-the-past-30-days-i) | Easy |
| <span id="1140">1140</span> | [Stone Game II](https://leetcode.com/problems/stone-game-ii "石子游戏 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/stone-game-ii) | Medium |
| <span id="1139">1139</span> | [Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square "最大的以 1 为边界的正方形") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-1-bordered-square) | Medium |
Expand Down
72 changes: 72 additions & 0 deletions problems/count-servers-that-communicate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!--|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](https://github.com/openset/leetcode/tree/master/problems/minimum-time-visiting-all-points "Minimum Time Visiting All Points")

[Next >](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system "Search Suggestions System")

## [1267. Count Servers that Communicate (Medium)](https://leetcode.com/problems/count-servers-that-communicate "统计参与通信的服务器")

<p>You are given a map of a server center, represented as a <code>m * n</code> integer matrix&nbsp;<code>grid</code>, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.<br />
<br />
Return the number of servers&nbsp;that communicate with any other server.</p>

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

<p><img alt="" src="https://assets.leetcode.com/uploads/2019/11/14/untitled-diagram-6.jpg" style="width: 202px; height: 203px;" /></p>

<pre>
<strong>Input:</strong> grid = [[1,0],[0,1]]
<strong>Output:</strong> 0
<b>Explanation:</b>&nbsp;No servers can communicate with others.</pre>

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

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/11/13/untitled-diagram-4.jpg" style="width: 203px; height: 203px;" /></strong></p>

<pre>
<strong>Input:</strong> grid = [[1,0],[1,1]]
<strong>Output:</strong> 3
<b>Explanation:</b>&nbsp;All three servers can communicate with at least one other server.
</pre>

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

<p><img alt="" src="https://assets.leetcode.com/uploads/2019/11/14/untitled-diagram-1-3.jpg" style="width: 443px; height: 443px;" /></p>

<pre>
<strong>Input:</strong> grid = [[1,1,0,0],[0,0,1,0],[0,0,1,0],[0,0,0,1]]
<strong>Output:</strong> 4
<b>Explanation:</b>&nbsp;The two servers in the first row can communicate with each other. The two servers in the third column can communicate with each other. The server at right bottom corner can&#39;t communicate with any other server.
</pre>

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

<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>1 &lt;= m &lt;= 250</code></li>
<li><code>1 &lt;= n &lt;= 250</code></li>
<li><code>grid[i][j] == 0 or 1</code></li>
</ul>

### Related Topics
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Store number of computer in each row and column.
</details>

<details>
<summary>Hint 2</summary>
Count all servers that are not isolated.
</details>
2 changes: 1 addition & 1 deletion problems/design-linked-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-hashmap "Design HashMap")

[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-cyclic-sorted-list "Insert into a Cyclic Sorted List")
[Next >](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list "Insert into a Sorted Circular Linked List")

## [707. Design Linked List (Medium)](https://leetcode.com/problems/design-linked-list "设计链表")

Expand Down

This file was deleted.

This file was deleted.

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

[Next >](https://github.com/openset/leetcode/tree/master/problems/to-lower-case "To Lower Case")

## [708. Insert into a Cyclic Sorted List (Medium)](https://leetcode.com/problems/insert-into-a-cyclic-sorted-list "循环有序列表的插入")
## [708. Insert into a Sorted Circular Linked List (Medium)](https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list "循环有序列表的插入")



Expand Down
2 changes: 1 addition & 1 deletion problems/insertion-sort-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ With each iteration one element (red) is removed from the input data and inserte

### Similar Questions
1. [Sort List](https://github.com/openset/leetcode/tree/master/problems/sort-list) (Medium)
1. [Insert into a Cyclic Sorted List](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-cyclic-sorted-list) (Medium)
1. [Insert into a Sorted Circular Linked List](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-sorted-circular-linked-list) (Medium)
28 changes: 28 additions & 0 deletions problems/logger-rate-limiter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,35 @@

## [359. Logger Rate Limiter (Easy)](https://leetcode.com/problems/logger-rate-limiter "日志速率限制器")

<p>Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is <b>not printed in the last 10 seconds</b>.</p>

<p>Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise returns false.</p>

<p>It is possible that several messages arrive roughly at the same time.</p>

<p><b>Example:</b></p>

<pre>
Logger logger = new Logger();

// logging string &quot;foo&quot; at timestamp 1
logger.shouldPrintMessage(1, &quot;foo&quot;); returns true;

// logging string &quot;bar&quot; at timestamp 2
logger.shouldPrintMessage(2,&quot;bar&quot;); returns true;

// logging string &quot;foo&quot; at timestamp 3
logger.shouldPrintMessage(3,&quot;foo&quot;); returns false;

// logging string &quot;bar&quot; at timestamp 8
logger.shouldPrintMessage(8,&quot;bar&quot;); returns false;

// logging string &quot;foo&quot; at timestamp 10
logger.shouldPrintMessage(10,&quot;foo&quot;); returns false;

// logging string &quot;foo&quot; at timestamp 11
logger.shouldPrintMessage(11,&quot;foo&quot;); returns true;
</pre>

### Related Topics
[[Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md)]
Expand Down
1 change: 0 additions & 1 deletion problems/maximum-depth-of-n-ary-tree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<pre>
<strong>Input:</strong> root = [1,null,3,2,4,null,5,6]
<strong>Output:</strong> 3
<strong>Explanation:</strong> Representation of 3-ary tree.
</pre>

<p><strong>Example 2:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

[< Previous](https://github.com/openset/leetcode/tree/master/problems/greatest-sum-divisible-by-three "Greatest Sum Divisible by Three")

Next >
[Next >](https://github.com/openset/leetcode/tree/master/problems/page-recommendations "Page Recommendations")

## [1263. Minimum Moves to Move a Box to Their Target Location (Hard)](https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location "推箱子")

<p>Storekeeper is a&nbsp;game, in which the player pushes boxes around in a warehouse, trying to get them to target locations.</p>
<p>Storekeeper is a&nbsp;game&nbsp;in which the player pushes boxes around in a warehouse&nbsp;trying to get them to target locations.</p>

<p>The game is represented by a <code>grid</code> of size&nbsp;<code>n<font face="sans-serif, Arial, Verdana, Trebuchet MS">*</font></code><code>m</code>, where each element is a wall, floor&nbsp;or a box.</p>
<p>The game is represented by a <code>grid</code> of size&nbsp;<code>n<font face="sans-serif, Arial, Verdana, Trebuchet MS">*</font></code><code>m</code>, where each element is a wall, floor, or a box.</p>

<p>Your task is move the box <code>&#39;B&#39;</code> to the target position <code>&#39;T&#39;</code> under the following rules:</p>

<ul>
<li>Player is represented by character <code>&#39;S&#39;</code>&nbsp;and&nbsp;can move up, down, left, right in the <code>grid</code> if its a floor (empy cell).</li>
<li>Player is represented by character <code>&#39;S&#39;</code>&nbsp;and&nbsp;can move up, down, left, right in the <code>grid</code> if it is a floor (empy cell).</li>
<li>Floor is represented by character <code>&#39;.&#39;</code> that means free cell to walk.</li>
<li>Wall is represented by character <code>&#39;#&#39;</code> that means obstacle&nbsp;&nbsp;(impossible to walk there).&nbsp;</li>
<li>There is only one box <code>&#39;B&#39;</code> and one&nbsp;target cell <code>&#39;T&#39;</code> in the <code>grid</code>.</li>
Expand Down
69 changes: 69 additions & 0 deletions problems/minimum-time-visiting-all-points/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 <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/print-immutable-linked-list-in-reverse "Print Immutable Linked List in Reverse")

[Next >](https://github.com/openset/leetcode/tree/master/problems/count-servers-that-communicate "Count Servers that Communicate")

## [1266. Minimum Time Visiting All Points (Easy)](https://leetcode.com/problems/minimum-time-visiting-all-points "访问所有点的最小时间")

<p>On a plane there are <code>n</code> points with integer coordinates <code>points[i] = [xi, yi]</code>. Your task is to find the minimum time in seconds to visit all points.</p>

<p>You can move according to the next rules:</p>

<ul>
<li>In one second always you can either move vertically, horizontally by one unit or diagonally (it means to move one unit vertically and one unit horizontally in one second).</li>
<li>You have to visit the points in the same order as they appear in the array.</li>
</ul>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2019/11/14/1626_example_1.PNG" style="width: 500px; height: 428px;" />
<pre>
<strong>Input:</strong> points = [[1,1],[3,4],[-1,0]]
<strong>Output:</strong> 7
<strong>Explanation: </strong>One optimal path is <strong>[1,1]</strong> -&gt; [2,2] -&gt; [3,3] -&gt; <strong>[3,4] </strong>-&gt; [2,3] -&gt; [1,2] -&gt; [0,1] -&gt; <strong>[-1,0]</strong>
Time from [1,1] to [3,4] = 3 seconds
Time from [3,4] to [-1,0] = 4 seconds
Total time = 7 seconds</pre>

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

<pre>
<strong>Input:</strong> points = [[3,2],[-2,2]]
<strong>Output:</strong> 5
</pre>

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

<ul>
<li><code>points.length == n</code></li>
<li><code>1 &lt;= n&nbsp;&lt;= 100</code></li>
<li><code>points[i].length == 2</code></li>
<li><code>-1000&nbsp;&lt;= points[i][0], points[i][1]&nbsp;&lt;= 1000</code></li>
</ul>

### Related Topics
[[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)]
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
To walk from point A to point B there will be an optimal strategy to walk ?
</details>

<details>
<summary>Hint 2</summary>
Advance in diagonal as possible then after that go in straight line.
</details>

<details>
<summary>Hint 3</summary>
Repeat the process until visiting all the points.
</details>
Loading