Skip to content

Commit 7172e7e

Browse files
author
openset
committed
Update: daily
1 parent e485e24 commit 7172e7e

File tree

19 files changed

+60
-16
lines changed

19 files changed

+60
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65+
| <span id="1270">1270</span> | [All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/all-people-report-to-the-given-manager) | Medium |
6566
| <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 |
6667
| <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 |
6768
| <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 |

internal/leetcode/question_data.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,25 @@ func (question *questionType) RenamePackageName() {
224224
}
225225
}
226226

227+
func (question *questionType) Restore() {
228+
filename := question.getFilePath("README.md")
229+
body := fileGetContents(filename)
230+
pattern := `## [^\n]+\n\n([\S\s]+)`
231+
if bytes.Contains(body, []byte("\n### ")) {
232+
pattern = `## [^\n]+\n\n([\S\s]+?)\n### `
233+
}
234+
reg := regexp.MustCompile(pattern)
235+
matches := reg.FindSubmatch(body)
236+
if len(matches) >= 2 {
237+
return
238+
}
239+
question.Content = string(matches[1])
240+
name := fmt.Sprintf(questionDataFile, question.TitleSnake())
241+
filePutContents(getCachePath(name), jsonEncode(QuestionDataType{
242+
Data: dataType{Question: *question},
243+
}))
244+
}
245+
227246
func (question *questionType) getSimilarQuestion() []byte {
228247
sq := question.GetSimilarQuestion()
229248
var buf bytes.Buffer
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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/number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps")
9+
                
10+
Next >
11+
12+
## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "")
13+
14+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Create table If Not Exists Employees (employee_id int, employee_name varchar(30), manager_id int);
2+
Truncate table Employees;
3+
insert into Employees (employee_id, employee_name, manager_id) values ('1', 'Boss', '1');
4+
insert into Employees (employee_id, employee_name, manager_id) values ('3', 'Alice', '3');
5+
insert into Employees (employee_id, employee_name, manager_id) values ('2', 'Bob', '1');
6+
insert into Employees (employee_id, employee_name, manager_id) values ('4', 'Daniel', '2');
7+
insert into Employees (employee_id, employee_name, manager_id) values ('7', 'Luis', '4');
8+
insert into Employees (employee_id, employee_name, manager_id) values ('8', 'John', '3');
9+
insert into Employees (employee_id, employee_name, manager_id) values ('9', 'Angela', '8');
10+
insert into Employees (employee_id, employee_name, manager_id) values ('77', 'Robert', '1');

problems/longest-substring-with-at-most-k-distinct-characters/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
### Similar Questions
3939
1. [Longest Substring Without Repeating Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) (Medium)
40-
1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Hard)
40+
1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium)
4141
1. [Longest Repeating Character Replacement](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) (Medium)
4242
1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard)
4343
1. [Max Consecutive Ones III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) (Medium)

problems/longest-substring-with-at-most-two-distinct-characters/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists "Intersection of Two Linked Lists")
1111

12-
## [159. Longest Substring with At Most Two Distinct Characters (Hard)](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串")
12+
## [159. Longest Substring with At Most Two Distinct Characters (Medium)](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串")
1313

1414
<p>Given a string <strong><em>s</em></strong> , find the length of the longest substring&nbsp;<strong><em>t&nbsp;&nbsp;</em></strong>that contains <strong>at most </strong>2 distinct characters.</p>
1515

problems/longest-substring-without-repeating-characters/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@
5151
[[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)]
5252

5353
### Similar Questions
54-
1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Hard)
54+
1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium)
5555
1. [Longest Substring with At Most K Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-k-distinct-characters) (Hard)
5656
1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard)

problems/majority-element/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design "Two Sum III - Data structure design")
1111

12-
## [169. Majority Element (Easy)](https://leetcode.com/problems/majority-element "求众数")
12+
## [169. Majority Element (Easy)](https://leetcode.com/problems/majority-element "多数元素")
1313

1414
<p>Given an array of size <i>n</i>, find the majority element. The majority element is the element that appears <b>more than</b> <code>&lfloor; n/2 &rfloor;</code> times.</p>
1515

problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/search-suggestions-system "Search Suggestions System")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/all-people-report-to-the-given-manager "All People Report to the Given Manager")
1111

1212
## [1269. Number of Ways to Stay in the Same Place After Some Steps (Hard)](https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps "停在原地的方案数")
1313

problems/sliding-window-maximum/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Could you solve it in linear time?</p>
4343
### Similar Questions
4444
1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard)
4545
1. [Min Stack](https://github.com/openset/leetcode/tree/master/problems/min-stack) (Easy)
46-
1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Hard)
46+
1. [Longest Substring with At Most Two Distinct Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) (Medium)
4747
1. [Paint House II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) (Hard)
4848

4949
### Hints

0 commit comments

Comments
 (0)