Skip to content

Commit 6832936

Browse files
author
openset
committed
Update: daily update
1 parent d8220d4 commit 6832936

File tree

8 files changed

+108
-6
lines changed

8 files changed

+108
-6
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65+
| <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 |
6566
| <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 |
6667
| <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 |
6768
| <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 |

Diff for: problems/design-linked-list/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

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

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

1414
<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>
1515

@@ -19,7 +19,7 @@
1919
<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>
2020
<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>
2121
<li>addAtTail(val) : Append a node of value <code>val</code>&nbsp;to the last element of the linked list.</li>
22-
<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>
22+
<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>
2323
<li>deleteAtIndex(index) : Delete&nbsp;the <code>index</code>-th&nbsp;node in the linked list, if the index is valid.</li>
2424
</ul>
2525

Diff for: problems/maximum-equal-frequency/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/dice-roll-simulation "Dice Roll Simulation")
99

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

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

Diff for: problems/report-contiguous-dates/README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-equal-frequency "Maximum Equal Frequency")
9+
                
10+
Next >
11+
12+
## [1225. Report Contiguous Dates (Hard)](https://leetcode.com/problems/report-contiguous-dates "")
13+
14+
<p>Table: <code>Failed</code></p>
15+
16+
<pre>
17+
+--------------+---------+
18+
| Column Name | Type |
19+
+--------------+---------+
20+
| fail_date | date |
21+
+--------------+---------+
22+
Primary key for this table is fail_date.
23+
Failed table contains the days of failed tasks.
24+
</pre>
25+
26+
<p>Table: <code>Succeeded</code></p>
27+
28+
<pre>
29+
+--------------+---------+
30+
| Column Name | Type |
31+
+--------------+---------+
32+
| success_date | date |
33+
+--------------+---------+
34+
Primary key for this table is success_date.
35+
Succeeded table contains the days of succeeded tasks.
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
40+
<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>
41+
42+
<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>
43+
44+
<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>
45+
46+
<p>Order result by <code>start_date</code>.</p>
47+
48+
<p>The query result format is in the following example:</p>
49+
50+
<pre>
51+
Failed table:
52+
+-------------------+
53+
| fail_date |
54+
+-------------------+
55+
| 2018-12-28 |
56+
| 2018-12-29 |
57+
| 2019-01-04 |
58+
| 2019-01-05 |
59+
+-------------------+
60+
61+
Succeeded table:
62+
+-------------------+
63+
| success_date |
64+
+-------------------+
65+
| 2018-12-30 |
66+
| 2018-12-31 |
67+
| 2019-01-01 |
68+
| 2019-01-02 |
69+
| 2019-01-03 |
70+
| 2019-01-06 |
71+
+-------------------+
72+
73+
74+
Result table:
75+
+--------------+--------------+--------------+
76+
| period_state | start date | end date |
77+
+--------------+--------------+--------------+
78+
| present | 2019-01-01 | 2019-01-03 |
79+
| missing | 2019-01-04 | 2019-01-05 |
80+
| present | 2019-01-06 | 2019-01-06 |
81+
+--------------+--------------+--------------+
82+
83+
The report ignored the system state in 2018 as we care about the system in the period 2019-01-01 to 2019-12-31.
84+
From 2019-01-01 to 2019-01-03 all tasks succeeded and the system state was &quot;present&quot;.
85+
From 2019-01-04 to 2019-01-05 all tasks failed and system state was &quot;missing&quot;.
86+
From 2019-01-06 to 2019-01-06 all tasks succeeded and system state was &quot;present&quot;.
87+
</pre>

Diff for: problems/report-contiguous-dates/mysql_schemas.sql

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Create table If Not Exists Failed (fail_date date);
2+
Create table If Not Exists Succeeded (success_date date);
3+
Truncate table Failed;
4+
insert into Failed (fail_date) values ('2018-12-28');
5+
insert into Failed (fail_date) values ('2018-12-29');
6+
insert into Failed (fail_date) values ('2019-01-04');
7+
insert into Failed (fail_date) values ('2019-01-05');
8+
Truncate table Succeeded;
9+
insert into Succeeded (success_date) values ('2018-12-30');
10+
insert into Succeeded (success_date) values ('2018-12-31');
11+
insert into Succeeded (success_date) values ('2019-01-01');
12+
insert into Succeeded (success_date) values ('2019-01-02');
13+
insert into Succeeded (success_date) values ('2019-01-03');
14+
insert into Succeeded (success_date) values ('2019-01-06');

Diff for: readme/601-900.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ LeetCode Problems' Solutions
168168
| <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 |
169169
| <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 |
170170
| <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 |
171-
| <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 |
171+
| <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 |
172172
| <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 |
173173
| <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 |
174174
| <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 |

Diff for: tag/design/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| 1172 | [餐盘栈](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks) | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Hard |
1414
| 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 |
1515
| 716 | [最大栈](https://github.com/openset/leetcode/tree/master/problems/max-stack) 🔒 | [[设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md)] | Easy |
16-
| 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 |
16+
| 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 |
1717
| 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 |
1818
| 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 |
1919
| 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 |

Diff for: tag/linked-list/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| 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 |
1616
| 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 |
1717
| 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 |
18-
| 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 |
18+
| 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 |
1919
| 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 |
2020
| 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 |
2121
| 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 |

0 commit comments

Comments
 (0)