Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update: daily #724

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
awesee merged 1 commit into master from develop
Nov 30, 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
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <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 |
| <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 |
Expand Down
19 changes: 19 additions & 0 deletions internal/leetcode/question_data.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,25 @@ func (question *questionType) RenamePackageName() {
}
}

func (question *questionType) Restore() {
filename := question.getFilePath("README.md")
body := fileGetContents(filename)
pattern := `## [^\n]+\n\n([\S\s]+)`
if bytes.Contains(body, []byte("\n### ")) {
pattern = `## [^\n]+\n\n([\S\s]+?)\n### `
}
reg := regexp.MustCompile(pattern)
matches := reg.FindSubmatch(body)
if len(matches) >= 2 {
return
}
question.Content = string(matches[1])
name := fmt.Sprintf(questionDataFile, question.TitleSnake())
filePutContents(getCachePath(name), jsonEncode(QuestionDataType{
Data: dataType{Question: *question},
}))
}

func (question *questionType) getSimilarQuestion() []byte {
sq := question.GetSimilarQuestion()
var buf bytes.Buffer
Expand Down
14 changes: 14 additions & 0 deletions problems/all-people-report-to-the-given-manager/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--|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/number-of-ways-to-stay-in-the-same-place-after-some-steps "Number of Ways to Stay in the Same Place After Some Steps")

Next >

## [1270. All People Report to the Given Manager (Medium)](https://leetcode.com/problems/all-people-report-to-the-given-manager "")


10 changes: 10 additions & 0 deletions problems/all-people-report-to-the-given-manager/mysql_schemas.sql
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Create table If Not Exists Employees (employee_id int, employee_name varchar(30), manager_id int);
Truncate table Employees;
insert into Employees (employee_id, employee_name, manager_id) values ('1', 'Boss', '1');
insert into Employees (employee_id, employee_name, manager_id) values ('3', 'Alice', '3');
insert into Employees (employee_id, employee_name, manager_id) values ('2', 'Bob', '1');
insert into Employees (employee_id, employee_name, manager_id) values ('4', 'Daniel', '2');
insert into Employees (employee_id, employee_name, manager_id) values ('7', 'Luis', '4');
insert into Employees (employee_id, employee_name, manager_id) values ('8', 'John', '3');
insert into Employees (employee_id, employee_name, manager_id) values ('9', 'Angela', '8');
insert into Employees (employee_id, employee_name, manager_id) values ('77', 'Robert', '1');
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

### Similar Questions
1. [Longest Substring Without Repeating Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) (Medium)
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)
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)
1. [Longest Repeating Character Replacement](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-character-replacement) (Medium)
1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard)
1. [Max Consecutive Ones III](https://github.com/openset/leetcode/tree/master/problems/max-consecutive-ones-iii) (Medium)
View file Open in desktop
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/intersection-of-two-linked-lists "Intersection of Two Linked Lists")

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

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

Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
[[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)]

### Similar Questions
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)
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)
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)
1. [Subarrays with K Different Integers](https://github.com/openset/leetcode/tree/master/problems/subarrays-with-k-different-integers) (Hard)
2 changes: 1 addition & 1 deletion problems/majority-element/README.md
View file Open in desktop
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/two-sum-iii-data-structure-design "Two Sum III - Data structure design")

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

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

Expand Down
View file Open in desktop
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/search-suggestions-system "Search Suggestions System")

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

## [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 "停在原地的方案数")

Expand Down
2 changes: 1 addition & 1 deletion problems/sliding-window-maximum/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Could you solve it in linear time?</p>
### Similar Questions
1. [Minimum Window Substring](https://github.com/openset/leetcode/tree/master/problems/minimum-window-substring) (Hard)
1. [Min Stack](https://github.com/openset/leetcode/tree/master/problems/min-stack) (Easy)
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)
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)
1. [Paint House II](https://github.com/openset/leetcode/tree/master/problems/paint-house-ii) (Hard)

### Hints
Expand Down
2 changes: 1 addition & 1 deletion problems/subarrays-with-k-different-integers/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@

### Similar Questions
1. [Longest Substring Without Repeating Characters](https://github.com/openset/leetcode/tree/master/problems/longest-substring-without-repeating-characters) (Medium)
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)
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)
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)
4 changes: 2 additions & 2 deletions readme/1-300.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ LeetCode Problems' Solutions
| <span id="156">156</span> | [Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down "上下翻转二叉树") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/binary-tree-upside-down) | Medium |
| <span id="157">157</span> | [Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4 "用 Read4 读取 N 个字符") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4) | Easy |
| <span id="158">158</span> | [Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times "用 Read4 读取 N 个字符 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/read-n-characters-given-read4-ii-call-multiple-times) | Hard |
| <span id="159">159</span> | [Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) | Hard |
| <span id="159">159</span> | [Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters "至多包含两个不同字符的最长子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-substring-with-at-most-two-distinct-characters) | Medium |
| <span id="160">160</span> | [Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists "相交链表") | [Go](https://github.com/openset/leetcode/tree/master/problems/intersection-of-two-linked-lists) | Easy |
| <span id="161">161</span> | [One Edit Distance](https://leetcode.com/problems/one-edit-distance "相隔为 1 的编辑距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance) | Medium |
| <span id="162">162</span> | [Find Peak Element](https://leetcode.com/problems/find-peak-element "寻找峰值") | [Go](https://github.com/openset/leetcode/tree/master/problems/find-peak-element) | Medium |
Expand All @@ -230,7 +230,7 @@ LeetCode Problems' Solutions
| <span id="166">166</span> | [Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal "分数到小数") | [Go](https://github.com/openset/leetcode/tree/master/problems/fraction-to-recurring-decimal) | Medium |
| <span id="167">167</span> | [Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted "两数之和 II - 输入有序数组") | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) | Easy |
| <span id="168">168</span> | [Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title "Excel表列名称") | [Go](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-title) | Easy |
| <span id="169">169</span> | [Majority Element](https://leetcode.com/problems/majority-element "求众数") | [Go](https://github.com/openset/leetcode/tree/master/problems/majority-element) | Easy |
| <span id="169">169</span> | [Majority Element](https://leetcode.com/problems/majority-element "多数元素") | [Go](https://github.com/openset/leetcode/tree/master/problems/majority-element) | Easy |
| <span id="170">170</span> | [Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii-data-structure-design "两数之和 III - 数据结构设计") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-iii-data-structure-design) | Easy |
| <span id="171">171</span> | [Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number "Excel表列序号") | [Go](https://github.com/openset/leetcode/tree/master/problems/excel-sheet-column-number) | Easy |
| <span id="172">172</span> | [Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes "阶乘后的零") | [Go](https://github.com/openset/leetcode/tree/master/problems/factorial-trailing-zeroes) | Easy |
Expand Down
2 changes: 1 addition & 1 deletion tag/array/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
| 216 | [组合总和 III](https://github.com/openset/leetcode/tree/master/problems/combination-sum-iii) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium |
| 209 | [长度最小的子数组](https://github.com/openset/leetcode/tree/master/problems/minimum-size-subarray-sum) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium |
| 189 | [旋转数组](https://github.com/openset/leetcode/tree/master/problems/rotate-array) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Easy |
| 169 | [求众数](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy |
| 169 | [多数元素](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy |
| 167 | [两数之和 II - 输入有序数组](https://github.com/openset/leetcode/tree/master/problems/two-sum-ii-input-array-is-sorted) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[双指针](https://github.com/openset/leetcode/tree/master/tag/two-pointers/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Easy |
| 163 | [缺失的区间](https://github.com/openset/leetcode/tree/master/problems/missing-ranges) 🔒 | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] | Medium |
| 162 | [寻找峰值](https://github.com/openset/leetcode/tree/master/problems/find-peak-element) | [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[二分查找](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)] | Medium |
Expand Down
2 changes: 1 addition & 1 deletion tag/bit-manipulation/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
| 191 | [位1的个数](https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy |
| 190 | [颠倒二进制位](https://github.com/openset/leetcode/tree/master/problems/reverse-bits) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Easy |
| 187 | [重复的DNA序列](https://github.com/openset/leetcode/tree/master/problems/repeated-dna-sequences) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Medium |
| 169 | [求众数](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy |
| 169 | [多数元素](https://github.com/openset/leetcode/tree/master/problems/majority-element) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)] | Easy |
| 137 | [只出现一次的数字 II](https://github.com/openset/leetcode/tree/master/problems/single-number-ii) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] | Medium |
| 136 | [只出现一次的数字](https://github.com/openset/leetcode/tree/master/problems/single-number) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[哈希表](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)] | Easy |
| 78 | [子集](https://github.com/openset/leetcode/tree/master/problems/subsets) | [[位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md)] [[数组](https://github.com/openset/leetcode/tree/master/tag/array/README.md)] [[回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)] | Medium |
Loading

AltStyle によって変換されたページ (->オリジナル) /