Skip to content

Update: daily update #689

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
Oct 18, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <span id="1225">1225</span> | [Report Contiguous Dates](https://leetcode.com/problems/report-contiguous-dates) | [MySQL](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates) | Hard |
| <span id="1224">1224</span> | [Maximum Equal Frequency](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency) | Hard |
| <span id="1223">1223</span> | [Dice Roll Simulation](https://leetcode.com/problems/dice-roll-simulation "掷骰子模拟") | [Go](https://github.com/openset/leetcode/tree/master/problems/dice-roll-simulation) | Medium |
| <span id="1222">1222</span> | [Queens That Can Attack the King](https://leetcode.com/problems/queens-that-can-attack-the-king "可以攻击国王的皇后") | [Go](https://github.com/openset/leetcode/tree/master/problems/queens-that-can-attack-the-king) | Medium |
Expand Down
4 changes: 2 additions & 2 deletions problems/design-linked-list/README.md
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/insert-into-a-cyclic-sorted-list "Insert into a Cyclic Sorted List")

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

<p>Design your&nbsp;implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly&nbsp;linked list should have two attributes: <code>val</code>&nbsp;and <code>next</code>. <code>val</code> is the value of the current node, and <code>next</code>&nbsp;is&nbsp;a&nbsp;pointer/reference to the next node. If you want to use the doubly linked list,&nbsp;you will need&nbsp;one more attribute <code>prev</code> to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed.</p>

Expand All @@ -19,7 +19,7 @@
<li>get(index) : Get the value of&nbsp;the <code>index</code>-th&nbsp;node in the linked list. If the index is invalid, return <code>-1</code>.</li>
<li>addAtHead(val) : Add a node of value <code>val</code>&nbsp;before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.</li>
<li>addAtTail(val) : Append a node of value <code>val</code>&nbsp;to the last element of the linked list.</li>
<li>addAtIndex(index, val) : Add a node of value <code>val</code>&nbsp;before the <code>index</code>-th&nbsp;node in the linked list.&nbsp;If <code>index</code>&nbsp;equals&nbsp;to the length of&nbsp;linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted.</li>
<li>addAtIndex(index, val) : Add a node of value <code>val</code>&nbsp;before the <code>index</code>-th&nbsp;node in the linked list.&nbsp;If <code>index</code>&nbsp;equals&nbsp;to the length of&nbsp;linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. If index is negative, the node will be inserted at the head&nbsp;of the list.</li>
<li>deleteAtIndex(index) : Delete&nbsp;the <code>index</code>-th&nbsp;node in the linked list, if the index is valid.</li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion problems/maximum-equal-frequency/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/dice-roll-simulation "Dice Roll Simulation")

Next >
[Next >](https://github.com/openset/leetcode/tree/master/problems/report-contiguous-dates "Report Contiguous Dates")

## [1224. Maximum Equal Frequency (Hard)](https://leetcode.com/problems/maximum-equal-frequency "最大相等频率")

Expand Down
87 changes: 87 additions & 0 deletions problems/report-contiguous-dates/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](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency "Maximum Equal Frequency")

Next >

## [1225. Report Contiguous Dates (Hard)](https://leetcode.com/problems/report-contiguous-dates "")

<p>Table: <code>Failed</code></p>

<pre>
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| fail_date | date |
+--------------+---------+
Primary key for this table is fail_date.
Failed table contains the days of failed tasks.
</pre>

<p>Table: <code>Succeeded</code></p>

<pre>
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| success_date | date |
+--------------+---------+
Primary key for this table is success_date.
Succeeded table contains the days of succeeded tasks.
</pre>

<p>&nbsp;</p>

<p>A system is running one task <strong>every day</strong>. Every task is independent of the previous tasks. The tasks can fail or succeed.</p>

<p>Write an SQL query to generate a report of&nbsp;<code>period_state</code> for each continuous interval of days in the period from&nbsp;<strong>2019-01-01</strong> to <strong>2019-12-31</strong>.</p>

<p><code>period_state</code> is <em>&#39;failed&#39;&nbsp;</em>if tasks in this interval failed or <em>&#39;succeeded&#39;</em>&nbsp;if tasks in this interval succeeded. Interval of days are retrieved as <code>start_date</code> and <code>end_date.</code></p>

<p>Order result by <code>start_date</code>.</p>

<p>The query result format is in the following example:</p>

<pre>
Failed table:
+-------------------+
| fail_date |
+-------------------+
| 2018-12-28 |
| 2018-12-29 |
| 2019-01-04 |
| 2019-01-05 |
+-------------------+

Succeeded table:
+-------------------+
| success_date |
+-------------------+
| 2018-12-30 |
| 2018-12-31 |
| 2019-01-01 |
| 2019-01-02 |
| 2019-01-03 |
| 2019-01-06 |
+-------------------+


Result table:
+--------------+--------------+--------------+
| period_state | start date | end date |
+--------------+--------------+--------------+
| present | 2019-01-01 | 2019-01-03 |
| missing | 2019-01-04 | 2019-01-05 |
| present | 2019-01-06 | 2019-01-06 |
+--------------+--------------+--------------+

The report ignored the system state in 2018 as we care about the system in the period 2019-01-01 to 2019-12-31.
From 2019-01-01 to 2019-01-03 all tasks succeeded and the system state was &quot;present&quot;.
From 2019-01-04 to 2019-01-05 all tasks failed and system state was &quot;missing&quot;.
From 2019-01-06 to 2019-01-06 all tasks succeeded and system state was &quot;present&quot;.
</pre>
14 changes: 14 additions & 0 deletions problems/report-contiguous-dates/mysql_schemas.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Create table If Not Exists Failed (fail_date date);
Create table If Not Exists Succeeded (success_date date);
Truncate table Failed;
insert into Failed (fail_date) values ('2018-12-28');
insert into Failed (fail_date) values ('2018-12-29');
insert into Failed (fail_date) values ('2019-01-04');
insert into Failed (fail_date) values ('2019-01-05');
Truncate table Succeeded;
insert into Succeeded (success_date) values ('2018-12-30');
insert into Succeeded (success_date) values ('2018-12-31');
insert into Succeeded (success_date) values ('2019-01-01');
insert into Succeeded (success_date) values ('2019-01-02');
insert into Succeeded (success_date) values ('2019-01-03');
insert into Succeeded (success_date) values ('2019-01-06');
2 changes: 1 addition & 1 deletion readme/601-900.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ LeetCode Problems' Solutions
| <span id="704">704</span> | [Binary Search](https://leetcode.com/problems/binary-search "二分查找") | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-search) | Easy |
| <span id="705">705</span> | [Design HashSet](https://leetcode.com/problems/design-hashset "设计哈希集合") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hashset) | Easy |
| <span id="706">706</span> | [Design HashMap](https://leetcode.com/problems/design-hashmap "设计哈希映射") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) | Easy |
| <span id="707">707</span> | [Design Linked List](https://leetcode.com/problems/design-linked-list "设计链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | Easy |
| <span id="707">707</span> | [Design Linked List](https://leetcode.com/problems/design-linked-list "设计链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | Medium |
| <span id="708">708</span> | [Insert into a Cyclic Sorted List](https://leetcode.com/problems/insert-into-a-cyclic-sorted-list "循环有序列表的插入") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-cyclic-sorted-list) | Medium |
| <span id="709">709</span> | [To Lower Case](https://leetcode.com/problems/to-lower-case "转换成小写字母") | [Go](https://github.com/openset/leetcode/tree/master/problems/to-lower-case) | Easy |
| <span id="710">710</span> | [Random Pick with Blacklist](https://leetcode.com/problems/random-pick-with-blacklist "黑名单中的随机数") | [Go](https://github.com/openset/leetcode/tree/master/problems/random-pick-with-blacklist) | Hard |
Expand Down
2 changes: 1 addition & 1 deletion tag/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| 1172 | [餐盘栈](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard |
| 1166 | [设计文件系统](https://github.com/openset/leetcode/tree/master/problems/design-file-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium |
| 716 | [最大栈](https://github.com/openset/leetcode/tree/master/problems/max-stack) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy |
| 707 | [设计链表](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy |
| 707 | [设计链表](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 706 | [设计哈希映射](https://github.com/openset/leetcode/tree/master/problems/design-hashmap) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy |
| 705 | [设计哈希集合](https://github.com/openset/leetcode/tree/master/problems/design-hashset) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy |
| 642 | [设计搜索自动补全系统](https://github.com/openset/leetcode/tree/master/problems/design-search-autocomplete-system) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md)] | Hard |
Expand Down
2 changes: 1 addition & 1 deletion tag/linked-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| 817 | [链表组件](https://github.com/openset/leetcode/tree/master/problems/linked-list-components) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 725 | [分隔链表](https://github.com/openset/leetcode/tree/master/problems/split-linked-list-in-parts) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 708 | [循环有序列表的插入](https://github.com/openset/leetcode/tree/master/problems/insert-into-a-cyclic-sorted-list) 🔒 | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 707 | [设计链表](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Easy |
| 707 | [设计链表](https://github.com/openset/leetcode/tree/master/problems/design-linked-list) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 445 | [两数相加 II](https://github.com/openset/leetcode/tree/master/problems/add-two-numbers-ii) | [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 430 | [扁平化多级双向链表](https://github.com/openset/leetcode/tree/master/problems/flatten-a-multilevel-doubly-linked-list) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] | Medium |
| 426 | [将二叉搜索树转化为排序的双向链表](https://github.com/openset/leetcode/tree/master/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) 🔒 | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Medium |
Expand Down