diff --git a/problems/convert-sorted-list-to-binary-search-tree/README.md b/problems/convert-sorted-list-to-binary-search-tree/README.md
index 7e011589c..e9e43f0a0 100644
--- a/problems/convert-sorted-list-to-binary-search-tree/README.md
+++ b/problems/convert-sorted-list-to-binary-search-tree/README.md
@@ -30,8 +30,8 @@ One possible answer is: [0,-3,9,-10,null,5], which represents the following heig
### Related Topics
- [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
[[Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md)]
+ [[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
### Similar Questions
1. [Convert Sorted Array to Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/convert-sorted-array-to-binary-search-tree) (Easy)
diff --git a/problems/day-of-the-year/README.md b/problems/day-of-the-year/README.md
index b204f31ba..173fb4a7f 100644
--- a/problems/day-of-the-year/README.md
+++ b/problems/day-of-the-year/README.md
@@ -51,3 +51,12 @@
date[4] == date[7] == '-'
, and all other date[i]
's are digits
date
represents a calendar date between Jan 1st, 1900 and Dec 31, 2019.
+
+### Related Topics
+ [[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
+
+### Hints
+
+Hint 1
+Have a integer array of how many days there are per month. February gets one extra day if its a leap year. Then, we can manually count the ordinal as day + (number of days in months before this one).
+
diff --git a/problems/find-words-that-can-be-formed-by-characters/README.md b/problems/find-words-that-can-be-formed-by-characters/README.md
new file mode 100644
index 000000000..cd10224e8
--- /dev/null
+++ b/problems/find-words-that-can-be-formed-by-characters/README.md
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+[< Previous](https://github.com/openset/leetcode/tree/master/problems/market-analysis-ii "Market Analysis II")
+
+[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-level-sum-of-a-binary-tree "Maximum Level Sum of a Binary Tree")
+
+## 1160. Find Words That Can Be Formed by Characters (Easy)
+
+You are given an array of strings words
and a string chars
.
+
+A string is good if it can be formed by characters from chars
(each character can only be used once).
+
+Return the sum of lengths of all good strings in words
.
+
+
+
+Example 1:
+
+
+Input: words = ["cat","bt","hat","tree"], chars = "atach"
+Output: 6
+Explanation:
+The strings that can be formed are "cat" and "hat" so the answer is 3 + 3 = 6.
+
+
+Example 2:
+
+
+Input: words = ["hello","world","leetcode"], chars = "welldonehoneyr"
+Output: 10
+Explanation:
+The strings that can be formed are "hello" and "world" so the answer is 5 + 5 = 10.
+
+
+
+
+Note:
+
+
+ 1 <= words.length <= 1000
+ 1 <= words[i].length, chars.length <= 100
+ - All strings contain lowercase English letters only.
+
+
+### Related Topics
+ [[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
+ [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
+
+### Hints
+
+Hint 1
+Solve the problem for each string in words
independently.
+
+
+
+Hint 2
+Now try to think in frequency of letters.
+
+
+
+Hint 3
+Count how many times each character occurs in string chars
.
+
+
+
+Hint 4
+To form a string using characters from chars
, the frequency of each character in chars
must be greater than or equal the frequency of that character in the string to be formed.
+
diff --git a/problems/inorder-successor-in-bst/README.md b/problems/inorder-successor-in-bst/README.md
index 7b2f23db0..bc8d4b7a7 100644
--- a/problems/inorder-successor-in-bst/README.md
+++ b/problems/inorder-successor-in-bst/README.md
@@ -11,7 +11,34 @@
## 285. Inorder Successor in BST (Medium)
+Given a binary search tree and a node in it, find the in-order successor of that node in the BST.
+The successor of a node p
is the node with the smallest key greater than p.val
.
+
+
+
+Example 1:
+
+Input: root = [2,1,3], p = 1
+Output: 2
+Explanation: 1's in-order successor node is 2. Note that both p and the return value is of TreeNode type.
+
+
+Example 2:
+
+Input: root = [5,3,6,2,4,null,null,1], p = 6
+Output: null
+Explanation: There is no in-order successor of the current node, so the answer is null
.
+
+
+
+
+Note:
+
+
+ - If the given node has no in-order successor in the tree, return
null
.
+ - It's guaranteed that the values of the tree are unique.
+
### Related Topics
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
diff --git a/problems/last-substring-in-lexicographical-order/README.md b/problems/last-substring-in-lexicographical-order/README.md
new file mode 100644
index 000000000..0e01a431c
--- /dev/null
+++ b/problems/last-substring-in-lexicographical-order/README.md
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+[< Previous](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible "As Far from Land as Possible")
+
+Next >
+
+## 1163. Last Substring in Lexicographical Order (Hard)
+
+Given a string s
, return the last substring of s
in lexicographical order.
+
+
+
+Example 1:
+
+
+Input: "abab"
+Output: "bab"
+Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".
+
+
+Example 2:
+
+
+Input: "leetcode"
+Output: "tcode"
+
+
+
+
+Note:
+
+
+ 1 <= s.length <= 10^5
+ - s contains only lowercase English letters.
+
+
+### Related Topics
+ [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
+
+### Hints
+
+Hint 1
+Assume that the answer is a sub-string from index i to j. If you add the character at index j+1 you get a better answer.
+
+
+
+Hint 2
+The answer is always a suffix of the given string.
+
+
+
+Hint 3
+Since the limits are high, we need an efficient data structure.
+
+
+
+Hint 4
+Use suffix array.
+
diff --git a/problems/market-analysis-i/README.md b/problems/market-analysis-i/README.md
new file mode 100644
index 000000000..5df2b797b
--- /dev/null
+++ b/problems/market-analysis-i/README.md
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+[< Previous](https://github.com/openset/leetcode/tree/master/problems/online-majority-element-in-subarray "Online Majority Element In Subarray")
+
+[Next >](https://github.com/openset/leetcode/tree/master/problems/market-analysis-ii "Market Analysis II")
+
+## 1158. Market Analysis I (Medium)
+
+
diff --git a/problems/market-analysis-i/mysql_schemas.sql b/problems/market-analysis-i/mysql_schemas.sql
new file mode 100644
index 000000000..31eafa569
--- /dev/null
+++ b/problems/market-analysis-i/mysql_schemas.sql
@@ -0,0 +1,20 @@
+Create table If Not Exists Users (user_id int, join_date date, favorite_brand varchar(10));
+create table if not exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int);
+create table if not exists Items (item_id int, item_brand varchar(10));
+Truncate table Users;
+insert into Users (user_id, join_date, favorite_brand) values ('1', '2018-01-01', 'Lenovo');
+insert into Users (user_id, join_date, favorite_brand) values ('2', '2018-02-09', 'Samsung');
+insert into Users (user_id, join_date, favorite_brand) values ('3', '2018-01-19', 'LG');
+insert into Users (user_id, join_date, favorite_brand) values ('4', '2018-05-21', 'HP');
+Truncate table Orders;
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('1', '2019-08-01', '4', '1', '2');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('2', '2018-08-02', '2', '1', '3');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('3', '2019-08-03', '3', '2', '3');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('4', '2018-08-04', '1', '4', '2');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('5', '2018-08-04', '1', '3', '4');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('6', '2019-08-05', '2', '2', '4');
+Truncate table Items;
+insert into Items (item_id, item_brand) values ('1', 'Samsung');
+insert into Items (item_id, item_brand) values ('2', 'Lenovo');
+insert into Items (item_id, item_brand) values ('3', 'LG');
+insert into Items (item_id, item_brand) values ('4', 'HP');
diff --git a/problems/market-analysis-ii/README.md b/problems/market-analysis-ii/README.md
new file mode 100644
index 000000000..5b623f118
--- /dev/null
+++ b/problems/market-analysis-ii/README.md
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+[< Previous](https://github.com/openset/leetcode/tree/master/problems/market-analysis-i "Market Analysis I")
+
+[Next >](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters")
+
+## 1159. Market Analysis II (Hard)
+
+
diff --git a/problems/market-analysis-ii/mysql_schemas.sql b/problems/market-analysis-ii/mysql_schemas.sql
new file mode 100644
index 000000000..2932728aa
--- /dev/null
+++ b/problems/market-analysis-ii/mysql_schemas.sql
@@ -0,0 +1,20 @@
+Create table If Not Exists Users (user_id int, join_date date, favorite_brand varchar(10));
+create table if not exists Orders (order_id int, order_date date, item_id int, buyer_id int, seller_id int);
+create table if not exists Items (item_id int, item_brand varchar(10));
+Truncate table Users;
+insert into Users (user_id, join_date, favorite_brand) values ('1', '2019-01-01', 'Lenovo');
+insert into Users (user_id, join_date, favorite_brand) values ('2', '2019-02-09', 'Samsung');
+insert into Users (user_id, join_date, favorite_brand) values ('3', '2019-01-19', 'LG');
+insert into Users (user_id, join_date, favorite_brand) values ('4', '2019-05-21', 'HP');
+Truncate table Orders;
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('1', '2019-08-01', '4', '1', '2');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('2', '2019-08-02', '2', '1', '3');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('3', '2019-08-03', '3', '2', '3');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('4', '2019-08-04', '1', '4', '2');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('5', '2019-08-04', '1', '3', '4');
+insert into Orders (order_id, order_date, item_id, buyer_id, seller_id) values ('6', '2019-08-05', '2', '2', '4');
+Truncate table Items;
+insert into Items (item_id, item_brand) values ('1', 'Samsung');
+insert into Items (item_id, item_brand) values ('2', 'Lenovo');
+insert into Items (item_id, item_brand) values ('3', 'LG');
+insert into Items (item_id, item_brand) values ('4', 'HP');
diff --git a/problems/maximum-level-sum-of-a-binary-tree/README.md b/problems/maximum-level-sum-of-a-binary-tree/README.md
new file mode 100644
index 000000000..fec43eba2
--- /dev/null
+++ b/problems/maximum-level-sum-of-a-binary-tree/README.md
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-words-that-can-be-formed-by-characters "Find Words That Can Be Formed by Characters")
+
+[Next >](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible "As Far from Land as Possible")
+
+## 1161. Maximum Level Sum of a Binary Tree (Medium)
+
+Given the root
of a binary tree, the level of its root is 1
, the level of its children is 2
, and so on.
+
+Return the smallest level X
such that the sum of all the values of nodes at level X
is maximal.
+
+
+
+Example 1:
+
+
+
+
+Input: [1,7,0,7,-8,null,null]
+Output: 2
+Explanation:
+Level 1 sum = 1.
+Level 2 sum = 7 + 0 = 7.
+Level 3 sum = 7 + -8 = -1.
+So we return the level with the maximum sum which is level 2.
+
+
+
+
+Note:
+
+
+ - The number of nodes in the given tree is between
1
and 10^4
.
+ -10^5 <= node.val <= 10^5
+
+
+### Related Topics
+ [[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]
+
+### Hints
+
+Hint 1
+Calculate the sum for each level then find the level with the maximum sum.
+
+
+
+Hint 2
+How can you traverse the tree ?
+
+
+
+Hint 3
+How can you sum up the values for every level ?
+
+
+
+Hint 4
+Use DFS or BFS to traverse the tree keeping the level of each node, and sum up those values with a map or a frequency array.
+
diff --git a/problems/online-majority-element-in-subarray/README.md b/problems/online-majority-element-in-subarray/README.md
index c96b54ddd..c39765f10 100644
--- a/problems/online-majority-element-in-subarray/README.md
+++ b/problems/online-majority-element-in-subarray/README.md
@@ -7,7 +7,7 @@
[< Previous](https://github.com/openset/leetcode/tree/master/problems/swap-for-longest-repeated-character-substring "Swap For Longest Repeated Character Substring")
-Next >
+[Next >](https://github.com/openset/leetcode/tree/master/problems/market-analysis-i "Market Analysis I")
## 1157. Online Majority Element In Subarray (Hard)
diff --git a/problems/shortest-distance-from-all-buildings/README.md b/problems/shortest-distance-from-all-buildings/README.md
index 02bf4bea6..c3d811537 100644
--- a/problems/shortest-distance-from-all-buildings/README.md
+++ b/problems/shortest-distance-from-all-buildings/README.md
@@ -19,3 +19,4 @@
### Similar Questions
1. [Walls and Gates](https://github.com/openset/leetcode/tree/master/problems/walls-and-gates) (Medium)
1. [Best Meeting Point](https://github.com/openset/leetcode/tree/master/problems/best-meeting-point) (Hard)
+ 1. [As Far from Land as Possible](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible) (Medium)
diff --git a/problems/swap-for-longest-repeated-character-substring/README.md b/problems/swap-for-longest-repeated-character-substring/README.md
index 3ea86537b..5f4cb4264 100644
--- a/problems/swap-for-longest-repeated-character-substring/README.md
+++ b/problems/swap-for-longest-repeated-character-substring/README.md
@@ -59,3 +59,13 @@
1 <= text.length <= 20000
text
consist of lowercase English characters only.
+
+### Related Topics
+ [[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
+
+### Hints
+
+Hint 1
+There are two cases: a block of characters, or two blocks of characters between one different character.
+ By keeping a run-length encoded version of the string, we can easily check these cases.
+
diff --git a/tag/README.md b/tag/README.md
index 099376dc1..862a51ec2 100644
--- a/tag/README.md
+++ b/tag/README.md
@@ -17,11 +17,11 @@
| 11 | [Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | [广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | | 12 | [Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) | [栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) |
| 13 | [Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md) | [回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md) | | 14 | [Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md) | [设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md) |
| 15 | [Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md) | [链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md) | | 16 | [Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) | [排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) |
-| 17 | [Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | [位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | | 18 | [Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) | [堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) |
-| 19 | [Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | [图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | | 20 | [Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) | [并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) |
+| 17 | [Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | [位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | | 18 | [Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | [图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) |
+| 19 | [Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) | [堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) | | 20 | [Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) | [并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) |
| 21 | [Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md) | [分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md) | | 22 | [Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md) | [Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md) |
| 23 | [Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md) | [字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md) | | 24 | [Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md) | [递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md) |
-| 25 | [Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md) | [Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md) | | 26 | [Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md) | [线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md) |
+| 25 | [Segment Tree](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md) | [线段树](https://github.com/openset/leetcode/tree/master/tag/segment-tree/README.md) | | 26 | [Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md) | [Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md) |
| 27 | [Queue](https://github.com/openset/leetcode/tree/master/tag/queue/README.md) | [队列](https://github.com/openset/leetcode/tree/master/tag/queue/README.md) | | 28 | [Minimax](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md) | [极小化极大](https://github.com/openset/leetcode/tree/master/tag/minimax/README.md) |
| 29 | [Binary Indexed Tree](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md) | [树状数组](https://github.com/openset/leetcode/tree/master/tag/binary-indexed-tree/README.md) | | 30 | [Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md) | [Random](https://github.com/openset/leetcode/tree/master/tag/random/README.md) |
| 31 | [Topological Sort](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md) | [拓扑排序](https://github.com/openset/leetcode/tree/master/tag/topological-sort/README.md) | | 32 | [Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md) | [脑筋急转弯](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md) |
diff --git a/tag/tags.json b/tag/tags.json
index e6ecbbdca..66241f62f 100644
--- a/tag/tags.json
+++ b/tag/tags.json
@@ -84,16 +84,16 @@
"Slug": "bit-manipulation",
"TranslatedName": "位运算"
},
- {
- "Name": "Heap",
- "Slug": "heap",
- "TranslatedName": "堆"
- },
{
"Name": "Graph",
"Slug": "graph",
"TranslatedName": "图"
},
+ {
+ "Name": "Heap",
+ "Slug": "heap",
+ "TranslatedName": "堆"
+ },
{
"Name": "Union Find",
"Slug": "union-find",
@@ -119,16 +119,16 @@
"Slug": "recursion",
"TranslatedName": "递归"
},
- {
- "Name": "Ordered Map",
- "Slug": "ordered-map",
- "TranslatedName": "Ordered Map"
- },
{
"Name": "Segment Tree",
"Slug": "segment-tree",
"TranslatedName": "线段树"
},
+ {
+ "Name": "Ordered Map",
+ "Slug": "ordered-map",
+ "TranslatedName": "Ordered Map"
+ },
{
"Name": "Queue",
"Slug": "queue",