diff --git a/Week_01/.idea/Week_01.iml b/Week_01/.idea/Week_01.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/Week_01/.idea/Week_01.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_01/.idea/encodings.xml b/Week_01/.idea/encodings.xml
new file mode 100644
index 00000000..15a15b21
--- /dev/null
+++ b/Week_01/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Week_01/.idea/misc.xml b/Week_01/.idea/misc.xml
new file mode 100644
index 00000000..28a804d8
--- /dev/null
+++ b/Week_01/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_01/.idea/modules.xml b/Week_01/.idea/modules.xml
new file mode 100644
index 00000000..c779e0d2
--- /dev/null
+++ b/Week_01/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_01/.idea/vcs.xml b/Week_01/.idea/vcs.xml
new file mode 100644
index 00000000..6c0b8635
--- /dev/null
+++ b/Week_01/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_01/.idea/workspace.xml b/Week_01/.idea/workspace.xml
new file mode 100644
index 00000000..ea700bc2
--- /dev/null
+++ b/Week_01/.idea/workspace.xml
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1560073881542
+
+
+ 1560073881542
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_01/id_1/LeetCode_15_1.java b/Week_01/id_1/LeetCode_15_1.java
index e6398698..f5728115 100644
--- a/Week_01/id_1/LeetCode_15_1.java
+++ b/Week_01/id_1/LeetCode_15_1.java
@@ -91,7 +91,6 @@ public List> threeSum3(int[] nums) {
for (int i = 0; i < nums.length - 2; i++) {
if (i == 0 || (i > 0 && nums[i] != nums[i - 1])) {
-
int left = i + 1, right = nums.length - 1, needValue = 0 - nums[i];
while (left < right) {
if (needValue == (nums[left] + nums[right])) {
@@ -114,3 +113,6 @@ public List> threeSum3(int[] nums) {
}
}
+
+
+// 左右指针的向中间逼近问题
\ No newline at end of file
diff --git a/Week_01/id_1/LeetCode_1_1.java b/Week_01/id_1/LeetCode_1_1.java
index 245502ec..97b43b57 100644
--- a/Week_01/id_1/LeetCode_1_1.java
+++ b/Week_01/id_1/LeetCode_1_1.java
@@ -51,3 +51,5 @@ public int[] twoSum2(int[] nums, int target) {
}
}
+
+ // format
diff --git a/Week_01/id_1/LeetCode_242_1.java b/Week_01/id_1/LeetCode_242_1.java
index cf0ae277..782fcdee 100644
--- a/Week_01/id_1/LeetCode_242_1.java
+++ b/Week_01/id_1/LeetCode_242_1.java
@@ -11,7 +11,7 @@
*/
public class ValidAnagram {
public static void main(String[] args) {
- ValidAnagram anagram = new ValidAnagram();
+ ValidAnagram anagram = new ValidAnagram(); // 注意这里的空格和格式
String s = "anagram", t = "nagaram";
System.out.println(anagram.isAnagram4(s,t));
}
diff --git "a/Week_01/id_1/\345\255\246\344\271\240\346\200\273\347\273\223.md" "b/Week_01/id_1/\345\255\246\344\271\240\346\200\273\347\273\223.md"
index be1093f5..bb6def69 100644
--- "a/Week_01/id_1/\345\255\246\344\271\240\346\200\273\347\273\223.md"
+++ "b/Week_01/id_1/\345\255\246\344\271\240\346\200\273\347\273\223.md"
@@ -4,9 +4,22 @@
每次提交代码时,都会非常的注意到执行完成的时间与使用的内存,再看看自己战胜了多少人。
我给自己自己定的目标是,超过 80% 的提交者,这样的话我觉得这个代码算是比较好的。
如果是只有超过 30% 及以下的提交者,那我会觉得这个代码会很low,往往是暴力法来解决的问题,会尝试着寻找新的满意的答案。
-当发现自己有时焦头烂额想不到好的办法的时候,阅读一下别人写的好的代码,那样的感觉 so cool.
-代码简洁而优雅,像是欣赏一位美丽优雅的女子一样,自己表现的专注而有神。
+当发现自己有时焦头烂额想不到好的办法的时候,阅读一下别人写的好的代码,那样的感觉 so cool.
+代码简洁而优雅,像是欣赏一位美丽优雅的女子一样,自己表现地专注而有神。
在学习数据结构与算法的过程当中,我觉得最重要的事情是 开拓了自己的思维。
以前自己想问题都是从前往后的线性结构,通过学习算法之后,学到了另外三种思维的方式。
1、从后往前;2、从中间向两端延伸;3、从两端向中间夹。
+
+1. 多种办法;
+2.
+3. 边界条件 、 时间空间复杂度(数据库、index、redis)
+
+# 五毒神掌
+
+非常好的总结;另外记得多看leetcode中文上的题解和国际版上的discuss专区
+
+"当发现自己有时焦头烂额想不到好的办法的时候,阅读一下别人写的好的代码,那样的感觉 so cool. 代码简洁而优雅,像是欣赏一位美丽优雅的女子一样,自己表现地专注而有神。"
+
+希望能坚持这样的训练法,继续保持! Keep it up!
+
diff --git a/Week_01/id_10/NOTE.md b/Week_01/id_10/NOTE.md
index 107ea7d6..cdc4a0f8 100644
--- a/Week_01/id_10/NOTE.md
+++ b/Week_01/id_10/NOTE.md
@@ -1 +1,4 @@
# 学习笔记
+
+
+Chao:题目完成数目很多,非常好。注意多看中文题解和国际站上的代码,进行代码优化。
\ No newline at end of file
diff --git "a/Week_01/id_12/\345\255\246\344\271\240\346\200\273\347\273\223.md" "b/Week_01/id_12/\345\255\246\344\271\240\346\200\273\347\273\223.md"
index f5be38a6..6955ce6b 100644
--- "a/Week_01/id_12/\345\255\246\344\271\240\346\200\273\347\273\223.md"
+++ "b/Week_01/id_12/\345\255\246\344\271\240\346\200\273\347\273\223.md"
@@ -10,4 +10,8 @@ a ^= b;
3.可以通过递归来解决链表问题;
4.可以通过素数相乘判断anagram;
5.数组合并的时候应该从后向前遍历;
-6.链表的相关操作其实就是指针(引用)的传递,操作之前注意引用的备份。
\ No newline at end of file
+6.链表的相关操作其实就是指针(引用)的传递,操作之前注意引用的备份。
+
+
+
+Chao:题目完成数目很多,非常好。注意多看中文题解和国际站上的代码,进行代码优化。 另外注意自己的代码格式,多用format plugin以及国际上通用的格式。
\ No newline at end of file
diff --git a/Week_01/id_13/LeetCode_101_013.js b/Week_01/id_13/LeetCode_101_013.js
index b66752af..6de3ff22 100644
--- a/Week_01/id_13/LeetCode_101_013.js
+++ b/Week_01/id_13/LeetCode_101_013.js
@@ -11,17 +11,17 @@
* https://leetcode.com/problems/symmetric-tree/
*/
var isSymmetric = function(root) {
-
+
if(!root) return root;
-
+
let isMirror= (left, right) => {
- if(!left && !right) return true;
- if(!left || !right) return false;
+ if (!left && !right) return true;
+ if (!left || !right) return false;
return (( left.val === right.val)
&& isMirror(left.left,right.right)
&& isMirror(left.right, right.left)
- )
- }
+ )
+ }
return isMirror(root.left, root.right);
};
diff --git a/Week_01/id_13/LeetCode_21_013.js b/Week_01/id_13/LeetCode_21_013.js
index eb4352b4..3caeea2b 100644
--- a/Week_01/id_13/LeetCode_21_013.js
+++ b/Week_01/id_13/LeetCode_21_013.js
@@ -19,19 +19,16 @@ var mergeTwoLists = function(l1, l2) {
let head = new ListNode(0);
let l = head;
while(l1)
- {
+ {
if(!l2)
{
l.next= l1;
break;
}
- if(l1.val <= l2.val)
- {
+ if (l1.val <= l2.val) {
l.next = l1;
l1=l1.next;
- }
- else
- {
+ } else {
l.next=l2;
l2=l2.next;
}
@@ -39,7 +36,7 @@ var mergeTwoLists = function(l1, l2) {
}
if(l2)
{
-
+
l.next = l2;
}
return head.next;
diff --git a/Week_01/id_13/NOTE.md b/Week_01/id_13/NOTE.md
index 107ea7d6..031fe4d0 100644
--- a/Week_01/id_13/NOTE.md
+++ b/Week_01/id_13/NOTE.md
@@ -1 +1,6 @@
# 学习笔记
+
+Chao:
+1. 代码格式需要加强
+2. 注意多看中文题解和国际站上的代码,进行代码优化。
+3. 代码逻辑的清晰性还有进一步提高的空间
\ No newline at end of file
diff --git a/Week_01/id_15/NOTE.md b/Week_01/id_15/NOTE.md
index cdab5526..7faa5445 100644
--- a/Week_01/id_15/NOTE.md
+++ b/Week_01/id_15/NOTE.md
@@ -37,13 +37,17 @@
33. 每种动态规划方案都涉及网络
34. 单元格中的值通通常就是要优化的值
35. 每个单元格都是一个子问题,因此你需要考虑如何将问题分解为子问题
-
+
2. Git视频课程30讲
2.1 核心内容笔记:https://mubu.com/doc/21G3uNP1Lw
-
+
3. 算法视频课程20节
4. 算法习题2题
## 下周规划
1. 读完半本(200页左右)的算法与数据结构Python语言描述
2. 继续刷剩余的算法题(上周剩余及本周新增)
+
+
+
+Chao: 非常好的总结!继续加油!
\ No newline at end of file
diff --git a/Week_01/id_16/242 b/Week_01/id_16/Solution.java
similarity index 91%
rename from Week_01/id_16/242
rename to Week_01/id_16/Solution.java
index 447e2fb6..ce43548b 100644
--- a/Week_01/id_16/242
+++ b/Week_01/id_16/Solution.java
@@ -1,4 +1,4 @@
-class Solution {
+public class Solution {
public boolean isAnagram(String s,String t)
{
char[] sChars=s.toCharArray();
diff --git a/Week_01/id_18/NOTE.md b/Week_01/id_18/NOTE.md
index cc683be0..011f11ee 100644
--- a/Week_01/id_18/NOTE.md
+++ b/Week_01/id_18/NOTE.md
@@ -7,9 +7,9 @@
示例 1:
```
-给定数组 nums = [1,1,2],
+给定数组 nums = [1,1,2],
-函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。
+函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。
你不需要考虑数组中超出新长度后面的元素。
```
@@ -52,7 +52,7 @@ class Solution {
nums[nonDuplicatesIndex++] = nums[i];
}
}
-
+
return nonDuplicatesIndex;
}
}
@@ -70,7 +70,7 @@ class Solution {
nums[nonDuplicatesIndex++] = nums[i];
}
}
-
+
return nonDuplicatesIndex;
}
}
@@ -88,7 +88,7 @@ class Solution {
}
nums[nonDuplicatesIndex++] = nums[i];
}
-
+
return nonDuplicatesIndex;
}
}
@@ -130,13 +130,13 @@ class Solution {
}
}
}
-
+
for (char c: tc) {
if (c != '#') {
return false;
}
}
-
+
return s.length() == t.length();
}
}
@@ -158,14 +158,14 @@ class Solution {
}
return false;
}
-
+
for (Long value: map.values()) {
if (value != 0) {
return false;
}
}
-
- return true;
+
+ return true;
}
}
```
@@ -230,18 +230,18 @@ class Solution {
char[] cs = s.toCharArray();
char[] ct = t.toCharArray();
int[] countArr = new int[26];
-
+
for (int i = 0; i < cs.length; i++) {
countArr[cs[i] - 'a']++;
countArr[ct[i] - 'a']--;
}
-
+
for (int i: countArr) {
if (i != 0) {
return false;
}
}
-
+
return ture;
}
}
@@ -306,7 +306,7 @@ class Solution {
if (S == null || "".equals(S)) {
return S;
}
-
+
Stack stack = new Stack<>();
for (char c: S.toCharArray()) {
if (stack.isEmpty() || stack.peek() != c) {
@@ -343,7 +343,7 @@ class Solution {
if (S == null || "".equals(S)) {
return S;
}
-
+
char[] cs = S.toCharArray();
int nonDuplicatesIndex = -1;
for (int i = 0; i < cs.length; i++) {
@@ -353,7 +353,7 @@ class Solution {
nonDuplicatesIndex--;
}
}
-
+
return new String(cs, 0, nonDuplicatesIndex + 1);
}
}
@@ -403,7 +403,7 @@ class Solution {
public int arrangeCoins(int n) {
return doJob(0, 0, n);
}
-
+
private int doJob(int level, int sum, int n) {
return sum + ++level > n ? --level : doJob(level, sum+level, n);
}
@@ -505,13 +505,13 @@ class Solution {
public int maxDepth(TreeNode root) {
return doSearch(0, root);
}
-
+
private int doSearch(int level, TreeNode root) {
//terminator
if (root == null) {
return level;
}
- //prepare
+ //prepare
level++;
//subproblems & prepare & generate result
return Math.max(doSearch(level, root.left), doSearch(level, root.right));
@@ -549,7 +549,7 @@ public class LeetCode_104_18 {
```
输入: [-1,-100,3,99] 和 k = 2
输出: [3,99,-1,-100]
-解释:
+解释:
向右旋转 1 步: [99,-1,-100,3]
向右旋转 2 步: [3,99,-1,-100]
```
@@ -564,12 +564,12 @@ class Solution {
if (nums == null || nums.length == 0) {
return;
}
-
+
for (int i = 0; i < k; i++) {
doMove(nums);
}
}
-
+
private void doMove(int[] nums) {
int store = nums[0];
for (int i = 0; i < nums.length - 1; i++) {
@@ -601,7 +601,7 @@ class Solution {
if (k == 0 || nums == null || nums.length <= 1 || (k % nums.length == 0)) {
return;
}
-
+
int index = 0;
int start = 0;
int store = nums[index];
@@ -630,14 +630,14 @@ class Solution {
if (k == 0 || nums == null || nums.length < 2 || k % nums.length == 0) {
return;
}
-
+
k %= nums.length;
-
+
swap(nums, 0, nums.length - 1);
swap(nums, 0, k - 1);
swap(nums, k, nums.length - 1);
}
-
+
private void swap(int[] nums, int head, int tail) {
while (head < tail) {
exchange(nums, head, tail);
@@ -645,7 +645,7 @@ class Solution {
tail--;
}
}
-
+
private void exchange(int[] nums, int x, int y) {
nums[x] ^= nums[y];
nums[y] ^= nums[x];
@@ -683,33 +683,33 @@ class Solution {
if (nums == null || nums.length < 3) {
return Collections.emptyList();
}
-
+
Arrays.sort(nums);
List> result = new ArrayList<>();
-
+
int pointer = 0, head, tail, target;
while (pointer < nums.length - 2) {
if (pointer > 0 && nums[pointer] == nums[pointer - 1]) {
pointer++;
continue;
}
-
+
head = pointer + 1;
tail = nums.length - 1;
target = -nums[pointer];
-
+
while (head < tail) {
if (nums[head] + nums[tail] == target) {
result.add(Arrays.asList(nums[pointer], nums[head], nums[tail]));
-
+
while (head < tail && nums[head] == nums[head + 1]) {
head++;
}
-
+
while (head < tail && nums[tail - 1] == nums[tail]) {
tail--;
}
-
+
head++;
tail--;
} else if (nums[head] + nums[tail] < target) {
@@ -718,10 +718,10 @@ class Solution {
tail--;
}
}
-
+
pointer++;
}
-
+
return result;
}
}
@@ -791,8 +791,8 @@ class Solution {
public List> groupAnagrams(String[] strs) {
if (strs == null || strs.length == 0) {
return Collections.emptyList();
- }
-
+ }
+
Map> map = new HashMap<>();
for (String s: strs) {
char[] cs = s.toCharArray();
@@ -803,7 +803,7 @@ class Solution {
}
map.get(tmp).add(s);
}
- return new ArrayList<>(map.values());
+ return new ArrayList<>(map.values());
}
}
```
@@ -971,20 +971,20 @@ class Solution {
public boolean isSymmetric(TreeNode root) {
return doCheck(root, root);
}
-
+
private boolean doCheck(TreeNode left, TreeNode right) {
if (left == null && right == null) {
return true;
}
-
+
if (left == null || right == null) {
return false;
}
-
+
return (left.val == right.val) && doCheck(left.left, right.right) && doCheck(left.right, right.left);
}
}
-```
+```
### 解法二
#### 思路
思路和解法一的递归类似,使用近似BFS的方式来解
@@ -995,23 +995,23 @@ class Solution {
Queue queue = new LinkedList<>();
queue.add(root);
queue.add(root);
-
+
while (!queue.isEmpty()) {
TreeNode left = queue.poll();
TreeNode right = queue.poll();
-
+
if (left == null && right == null) {
continue;
}
-
+
if (left == null || right == null) {
return false;
}
-
+
if (left.val != right.val) {
return false;
}
-
+
queue.add(left.left);
queue.add(right.right);
queue.add(left.right);
@@ -1031,23 +1031,23 @@ class Solution {
Stack stack = new Stack<>();
stack.push(root);
stack.push(root);
-
+
while (!stack.isEmpty()) {
TreeNode left = stack.pop();
TreeNode right = stack.pop();
-
+
if (left == null && right == null) {
continue;
}
-
+
if (left == null || right == null) {
return false;
}
-
+
if (left.val != right.val) {
return false;
}
-
+
stack.push(left.left);
stack.push(right.right);
stack.push(left.right);
@@ -1075,4 +1075,9 @@ class Solution {
7. 继续遍历,循环往复。
#### 代码
-### 收获
\ No newline at end of file
+### 收获
+
+
+
+
+Chao:非常好的总结。继续保持这样的方式进行训练和刷题下去。注意多看中文题解和国际站上的代码,进行代码优化!
\ No newline at end of file
diff --git a/Week_01/id_2/LeetCode_111_2.java b/Week_01/id_2/LeetCode_111_2.java
index c39a6bfd..ba2a1c8f 100644
--- a/Week_01/id_2/LeetCode_111_2.java
+++ b/Week_01/id_2/LeetCode_111_2.java
@@ -2,12 +2,12 @@
/**
* Given a binary tree, find its minimum depth.
- *
+ *
* The minimum depth is the number of nodes along the shortest path from the
* root node down to the nearest leaf node.
- *
+ *
* Note: A leaf is a node with no children.
- *
+ *
* @author liliangzi
*
*/
@@ -21,6 +21,9 @@ public int minDepth(TreeNode root) {
return 0;
int left = minDepth(root.left);
int right = minDepth(root.right);
+
+
+ // 简化代码,用三目运算符
if (right == 0)
return left + 1;
if (left == 0)
@@ -28,6 +31,6 @@ public int minDepth(TreeNode root) {
return Math.min(left, right) + 1;
}
-
-
+
+
}
diff --git a/Week_01/id_2/LeetCode_15_2.java b/Week_01/id_2/LeetCode_15_2.java
index cf97b96b..74af2cc2 100644
--- a/Week_01/id_2/LeetCode_15_2.java
+++ b/Week_01/id_2/LeetCode_15_2.java
@@ -9,15 +9,15 @@
* Given an array nums of n integers, are there elements a, b, c in nums such
* that a + b + c = 0? Find all unique triplets in the array which gives the sum
* of zero.
- *
+ *
* Note:
- *
+ *
* The solution set must not contain duplicate triplets.
- *
+ *
* Given array nums = [-1, 0, 1, 2, -1, -4],
- *
+ *
* A solution set is: [ [-1, 0, 1], [-1, -1, 2] ]
- *
+ *
* @author liliangzi
*
*/
@@ -25,10 +25,13 @@ public class LeetCode_15_2 {
/**
* Output limit exceeded brutal force
- *
+ *
* @param nums
* @return
*/
+
+ // 很好!!!
+
public List> threeSumExceedOutputLimit(int[] nums) {
List> list = new ArrayList>();
for (int i = 0; i < nums.length; i++) {
@@ -44,7 +47,7 @@ public List> threeSumExceedOutputLimit(int[] nums) {
/**
* have referenced discussion
- *
+ *
* @param nums
* @return
*/
diff --git a/Week_01/id_2/LeetCode_235_2.java b/Week_01/id_2/LeetCode_235_2.java
index f7703bd6..ad6d9eca 100644
--- a/Week_01/id_2/LeetCode_235_2.java
+++ b/Week_01/id_2/LeetCode_235_2.java
@@ -6,10 +6,10 @@
/**
* Given a binary search tree, find the lowest common ancestor (LCA) of two
* given nodes in the bst.
- *
+ *
* @author liliangzi
*
- *
+ *
* Definition for a binary tree node. public class TreeNode { int val;
* TreeNode left; TreeNode right; TreeNode(int x) { val = x; } }
*/
@@ -45,6 +45,9 @@ else if (p.val >= root.val && q.val >= root.val)
}
public TreeNode lowestCommonAncestor2(TreeNode root, TreeNode p, TreeNode q) {
+
+ // Chao: 如果有相应的return在if语句里的时候,建议能直接不需要else的分支。
+
if (root.val == p.val || root.val == q.val)
return root;
if ((p.val <= root.val && q.val >= root.val) || (p.val >= root.val && q.val <= root.val)) {
diff --git a/Week_01/id_2/NOTE.md b/Week_01/id_2/NOTE.md
index 107ea7d6..0482a11c 100644
--- a/Week_01/id_2/NOTE.md
+++ b/Week_01/id_2/NOTE.md
@@ -1 +1,4 @@
# 学习笔记
+
+
+Chao: 代码总体不错,没看到明显问题。 继续保持!
\ No newline at end of file
diff --git a/Week_01/id_23/NOTE.md b/Week_01/id_23/NOTE.md
index b4516261..d376e4f1 100644
--- a/Week_01/id_23/NOTE.md
+++ b/Week_01/id_23/NOTE.md
@@ -8,3 +8,6 @@
#### 关于递归 Recursion
“如果使用循环,程序地性能可能更高;如果适用递归,程序可能更容易理解。如何选择要看什么对你来说更重要” --Leigh Caldwell
递归套路模板 1. Recursion terminator2. Process logic 3.Drill down 4.Reverse the current level status if needed
+
+
+Chao:很不错的总结!希望保持这样的训练方法和势头,继续加油!
\ No newline at end of file
diff --git a/Week_01/id_24/NOTE.md b/Week_01/id_24/NOTE.md
index f46e8750..251c2839 100644
--- a/Week_01/id_24/NOTE.md
+++ b/Week_01/id_24/NOTE.md
@@ -11,3 +11,10 @@
现在没有优化的概念,基本就是把自己能想到的答案先码出来,除非题目特别要求,并没有认真计算解法的算法复杂度和空间复杂度。这周只完成了四道最简单的题目,希望下周每天都能打卡算法题,无论简单还是复杂,争取把它养成习惯。
Python 是一门很简洁的语言,我看了自己的解题代码,感觉很累赘,希望在这个月学习算法的过程中也能进一步深入学习 Python 。
+
+
+
+Chao:看到你重新开始学习python和开始训练算法和写代码,非常佩服和让人觉得inspiring。希望用五毒神掌的办法保持训练下去。
+
+有志者、事竟成,破釜沉舟,百二秦关终属楚;
+苦心人、天不负,卧薪尝胆,三千越甲可吞吴。
diff --git a/Week_01/id_25/NOTE.md b/Week_01/id_25/NOTE.md
index 832d00e0..99bd1253 100644
--- a/Week_01/id_25/NOTE.md
+++ b/Week_01/id_25/NOTE.md
@@ -5,7 +5,7 @@
2 自己学习态度的变化
平时在休息或思考时,分配了更多的精力思考算法问题
-
+
3 具体的算法学习思维
3.1 抓主干
3.2 总结规律 自己五分钟无解的 就先看答案
@@ -20,11 +20,11 @@
根据这个套路 我制定了一份基于斐波那契遗忘曲线的复习表
一定不要忘记老师说的 五毒神掌

-
+
4 在学习笔记里 主要提及宏观上的学习领悟
关于具体的题解思路 都详尽的写在题目里的注解里了
-5 分享一下记忆曲线复习表 即是TaskView.html
+5 分享一下记忆曲线复习表 即是TaskView.html
直接浏览器打开就能用 里面包含一段斐波那契递归函数呦
6 Review
@@ -36,14 +36,14 @@
1. 没有注解
尽管老师说要少些注解,但是由于我们是在练习、学习,必要的地方还是要加上注解,一个是给自己记忆,另一方面方便别的同学阅读,
另外,即使方法体、代码段里没有注解,在方法签名上也应有详细的doc和注解,阐述题意、解法、思路。
-
+
5.2 LeetCode_26_015.py
优点
1. 看了这个同学的readme,说自己不是科班,罗列了很多的学到的知识点,可以看出非常认真。
缺点
1. 同上,代码缺少必要的注解和说明
2. 解法偏少,只有一种解法。建议:除了自己思考的解法以外,也把其他解法实现一遍。
-
+
5.3 LeetCode_021_29.go
优点
1. 这个同学做了很多题。
@@ -51,7 +51,7 @@
3. 脑图画的很好
缺点
1. 没有题解doc
-
+
5.4 LeetCode_1047_022.js
优点
1. 代码格式整齐 清爽
@@ -59,15 +59,19 @@
缺点
1. 解法偏少
2. 没有题解doc
-
+
5.5 Leetcode_189_8.java
* 最喜欢的是这个同学的提交
优点
1. readme里面分门别类,格式整齐、详细的介绍了题目、难点分析、解题思路、参考代码
2. 脑图画的很好
缺点
- 1. 部分代码没有格式化
+ 1. 部分代码没有格式化
举例:
1. k%nums.length,符号和变量中间要有空格,改为k % nums.length
2. nums[i+k],改为 nums[i + k]
- 3. for (int i=0; i 全局最优解 找到最优子结构即可向上递推
递归 可以遍历所有解,这个是DP做不到的
+
+
+# 代码和总结都非常不错,希望能继续保持这样的状态下去! Keep it up!
\ No newline at end of file
diff --git a/Week_01/id_3/array/15/LeetCode_15_3_v1.py b/Week_01/id_3/array/15/LeetCode_15_3_v1.py
index 39c32709..efb287c5 100644
--- a/Week_01/id_3/array/15/LeetCode_15_3_v1.py
+++ b/Week_01/id_3/array/15/LeetCode_15_3_v1.py
@@ -52,3 +52,7 @@ def three_sum(nums):
r.append(arr)
return r
+
+
+# 需要进一步优化代码!
+# 优化很好
\ No newline at end of file
diff --git a/Week_01/id_3/bs/441/LeetCode_441_3_v2.py b/Week_01/id_3/bs/441/LeetCode_441_3_v2.py
index cce7fc27..92fd7be5 100644
--- a/Week_01/id_3/bs/441/LeetCode_441_3_v2.py
+++ b/Week_01/id_3/bs/441/LeetCode_441_3_v2.py
@@ -6,6 +6,10 @@ def arrange_coins(n):
return 0
k = 1
+ for (;;) {
+
+ }
+
while True:
s = int(((1 + k) * k)/2)
print(s, k)
@@ -14,3 +18,6 @@ def arrange_coins(n):
if s > n:
return k - 1
k += 1
+
+
+# 别这么搞
diff --git a/Week_01/id_3/hash/49/LeetCode_49_3_v1.py b/Week_01/id_3/hash/49/LeetCode_49_3_v1.py
index 9bbc7ebd..ce9c068c 100644
--- a/Week_01/id_3/hash/49/LeetCode_49_3_v1.py
+++ b/Week_01/id_3/hash/49/LeetCode_49_3_v1.py
@@ -7,3 +7,7 @@ def group_anagrams(strs):
m[k] = l
return list(m.values())
+
+
+
+# 非常好的代码!
\ No newline at end of file
diff --git a/Week_01/id_3/recursion/101/LeetCode_101_3_v1.py b/Week_01/id_3/recursion/101/LeetCode_101_3_v1.py
index 5b670cd7..f122c4bd 100644
--- a/Week_01/id_3/recursion/101/LeetCode_101_3_v1.py
+++ b/Week_01/id_3/recursion/101/LeetCode_101_3_v1.py
@@ -14,6 +14,7 @@ def is_symmetric(root):
return True
+# 可能逻辑上有bug
def is_mirror(queue):
length = len(queue)
@@ -22,6 +23,9 @@ def is_mirror(queue):
if length % 2 == 1:
return False
+ for (i ,j )
+
+ # 优化代码
for i in range(int(length/2)):
n1 = queue[i]
n2 = queue[length - i - 1]
diff --git a/Week_01/id_3/recursion/101/LeetCode_101_3_v2.py b/Week_01/id_3/recursion/101/LeetCode_101_3_v2.py
index 19a463bc..4d749695 100644
--- a/Week_01/id_3/recursion/101/LeetCode_101_3_v2.py
+++ b/Week_01/id_3/recursion/101/LeetCode_101_3_v2.py
@@ -13,10 +13,11 @@ def is_symmetric(root):
return is_mirror(root.left, root.right)
+
def is_mirror(t1, t2):
if not t1 and not t2:
return True
- if bool(t1) != bool(t2):
+ if bool(t1) != bool(t2): # bool ? the reason ?
return False
if t1.val != t2.val:
return False
diff --git a/Week_01/id_3/recursion/236/LeetCode_236_3_v1.py b/Week_01/id_3/recursion/236/LeetCode_236_3_v1.py
index bc223464..ae71f426 100644
--- a/Week_01/id_3/recursion/236/LeetCode_236_3_v1.py
+++ b/Week_01/id_3/recursion/236/LeetCode_236_3_v1.py
@@ -3,6 +3,9 @@ def lowest_common_ancestor(root, p, q):
return root
left = lowest_common_ancestor(root.left, p, q)
right = lowest_common_ancestor(root.right, p, q)
+
+
+ # 三目表达识
if left and right:
return root
return left or right
diff --git a/Week_01/id_32/NOTE.md b/Week_01/id_32/NOTE.md
index ba0a5240..9be29c23 100644
--- a/Week_01/id_32/NOTE.md
+++ b/Week_01/id_32/NOTE.md
@@ -3,3 +3,6 @@
一开始我自己写的时候写了两个循环,一个循环i,一个循环,结果提交失败。看了别人的解题思路才知道,用双指针思路即可。一个快指针,一个慢指针。慢指针不用循环遍历,只要快指针的判断条件到了,就更新慢指针
## 189. Rotate Array
这道题看似是数组移位问题,实际上是数据的翻转问题。我一开始傻乎乎地用移位来写,结果超时。后来才醒悟原来是数组翻转问题,移几位就是数组前面几位翻一下,剩下几位翻一下,再总的翻一下
+
+
+Chao:代码简洁,逻辑清晰。希望继续保持,同时多练习更多题目。
\ No newline at end of file
diff --git a/Week_01/id_33/NOTE.md b/Week_01/id_33/NOTE.md
index 107ea7d6..36ee7c67 100644
--- a/Week_01/id_33/NOTE.md
+++ b/Week_01/id_33/NOTE.md
@@ -1 +1,7 @@
# 学习笔记
+
+
+
+Chao: 代码总体看起来不错,继续保持联系。注意多看 leetcode 中文版的题解和国际版上的discuss高票代码。
+
+
diff --git a/Week_01/id_34/NOTE.md b/Week_01/id_34/NOTE.md
index 708c857d..7d248125 100644
--- a/Week_01/id_34/NOTE.md
+++ b/Week_01/id_34/NOTE.md
@@ -2,4 +2,8 @@
感谢大佬们分享
自己属于菜鸟一枚, 所以看到大佬们的各种思路有的激动, 这周写的题目不多, 只是完成了任务, 但是一题多解让我感觉到思考比答案更重要, 自己通过不断的看高手的解题, 不断加深自己的脑图,
-但是发现自己看到题目不会那么懵逼, 可以先遍历自己大脑思考一下
\ No newline at end of file
+但是发现自己看到题目不会那么懵逼, 可以先遍历自己大脑思考一下
+
+
+
+Chao: 代码总体看起来不错,继续保持联系。注意多看 leetcode 中文版的题解和国际版上的discuss高票代码。
\ No newline at end of file
diff --git a/Week_01/id_35/NOTE.md b/Week_01/id_35/NOTE.md
index 107ea7d6..3a4c77ea 100644
--- a/Week_01/id_35/NOTE.md
+++ b/Week_01/id_35/NOTE.md
@@ -1 +1,5 @@
# 学习笔记
+
+
+
+Chao: 代码看起来不够熟练; 多练习多写题目,多看别人的高票题解。
\ No newline at end of file
diff --git a/Week_01/id_36/NOTE.md b/Week_01/id_36/NOTE.md
index bd79c8e6..e6456f37 100644
--- a/Week_01/id_36/NOTE.md
+++ b/Week_01/id_36/NOTE.md
@@ -5,3 +5,10 @@
目前来到极客大学的算法集训营,就是希望给自己压力去突破这个算法,从老师那里学到了实用的五毒神掌的步骤,确实对算法的学习带来了很大的帮助,也希望接下来的算法作业自己能够多多的突破和解锁更多的思维方式。
在做《26.删除排序数组中的重复项》题目的时候,读题目的时候,受到题目中的删除这个词的影响,陷入到如何删除数组中的某一个元素,实际上题目是要求返回不同元素的个数。所以第一步需要先理解题目。所以读懂题目才是接下来思考的第一步。
+
+
+
+
+
+
+Chao:很不错的总结,再接再厉!
\ No newline at end of file
diff --git a/Week_01/id_37/NOTE.md b/Week_01/id_37/NOTE.md
index 3560db1f..6d488054 100644
--- a/Week_01/id_37/NOTE.md
+++ b/Week_01/id_37/NOTE.md
@@ -16,4 +16,8 @@
编写递归代码的关键是,只要遇到递归,我们就把它抽象成一个递推公式,不用想一层层的调用关系,不要试图用人脑去分解递归的每个步骤。
-https://www.processon.com/view/link/5cfcfa6ae4b071ad5a1cb631
\ No newline at end of file
+https://www.processon.com/view/link/5cfcfa6ae4b071ad5a1cb631
+
+
+
+Chao:很好的总结和算法题目分类;同时注意代码格式和优化代码逻辑。多看 leetcode 中文版的题解和国际版上的discuss高票代码。
\ No newline at end of file
diff --git a/Week_01/id_38/LeetCode_50_038.java b/Week_01/id_38/LeetCode_50_038.java
index 47e134b0..5e049036 100644
--- a/Week_01/id_38/LeetCode_50_038.java
+++ b/Week_01/id_38/LeetCode_50_038.java
@@ -8,6 +8,9 @@ public double myPow(double x, int n) {
if (n == 0) return 1.0;
double half = myPow(x, n / 2);
+
+
+ // 建议这里直接return三目运算符
if (n % 2 == 0) {
return half * half;
} else {
diff --git a/Week_01/id_38/NOTE.md b/Week_01/id_38/NOTE.md
index 107ea7d6..7df033ab 100644
--- a/Week_01/id_38/NOTE.md
+++ b/Week_01/id_38/NOTE.md
@@ -1 +1,3 @@
# 学习笔记
+
+Chao:代码逻辑非常清晰和简洁,继续保持和多练习其他题目。多看 leetcode 中文版的题解和国际版上的discuss高票代码。
\ No newline at end of file
diff --git a/Week_01/id_39/NOTE.md b/Week_01/id_39/NOTE.md
index 107ea7d6..6508539d 100644
--- a/Week_01/id_39/NOTE.md
+++ b/Week_01/id_39/NOTE.md
@@ -1 +1,4 @@
# 学习笔记
+
+
+Chao:代码清晰简洁好看,继续保持。看到你对于有点算法不是很理解,这个不用着急,多练习同时多反复即可。
\ No newline at end of file
diff --git a/Week_01/id_40/NOTE.md b/Week_01/id_40/NOTE.md
index 107ea7d6..073e698b 100644
--- a/Week_01/id_40/NOTE.md
+++ b/Week_01/id_40/NOTE.md
@@ -1 +1,3 @@
# 学习笔记
+
+Chao: 注意代码格式和优化代码逻辑。多看 leetcode 中文版的题解和国际版上的discuss高票代码。
diff --git a/Week_01/id_41/NOTE.md b/Week_01/id_41/NOTE.md
index f159ed65..42e3a1a6 100644
--- a/Week_01/id_41/NOTE.md
+++ b/Week_01/id_41/NOTE.md
@@ -1,3 +1,9 @@
# 学习笔记
递归代码看着的确很清爽。
C写起来会很累,CPP的vector>二维数组比C动态分配数组来通过指针计算方便很多。
+
+
+
+Chao: 代码总体看起来不错,继续保持联系。注意多看 leetcode 中文版的题解和国际版上的discuss高票代码。
+
+另外建议多尝试一些高级语言,比如 go(python)、js-es6 等,对于你对现在语言学习和理解有帮助。
\ No newline at end of file
diff --git a/Week_01/id_42/NOTE.md b/Week_01/id_42/NOTE.md
index 5a0a9848..6c318487 100644
--- a/Week_01/id_42/NOTE.md
+++ b/Week_01/id_42/NOTE.md
@@ -1,16 +1,19 @@
# 学习笔记
# [LeetCode174 题目](https://leetcode.com/problems/dungeon-game/)
-
+
这个题目主要利用动态规划,
- 需要反过来想,状态方程为:
-
+ 需要反过来想,状态方程为:
+
dp[i][j] = max(1, min(dp[i + 1][j], dp[i][j + 1]) - dungeon[i][j]);
-
-
-
+
+
+
# [leetCode368 题目](https://leetcode.com/problems/largest-divisible-subset/)
这个题目利用了stack 这种数据结构
- 时间复杂度为 0(n)
+ 时间复杂度为 0(n)
计算栈内数据的时候,有两个触发条件,当前数据并栈顶元素小了。或者到了最右端。
- 栈里面的元素是数据的下标,其实是用来计算矩形的宽度的。矩形的高度在出栈的时间就计算处理了。
\ No newline at end of file
+ 栈里面的元素是数据的下标,其实是用来计算矩形的宽度的。矩形的高度在出栈的时间就计算处理了。
+
+
+ Chao:很不错的总结。另外注意代码格式和优化代码逻辑。多看 leetcode 中文版的题解和国际版上的discuss高票代码。
\ No newline at end of file
diff --git a/Week_01/id_5/NOTE.md b/Week_01/id_5/NOTE.md
index 107ea7d6..50aa6e5d 100644
--- a/Week_01/id_5/NOTE.md
+++ b/Week_01/id_5/NOTE.md
@@ -1 +1,4 @@
# 学习笔记
+
+
+Chao:总体代码逻辑不错;注意代码格式
\ No newline at end of file
diff --git a/Week_01/id_6/NOTE.md b/Week_01/id_6/NOTE.md
index 189d22c3..a31ca375 100644
--- a/Week_01/id_6/NOTE.md
+++ b/Week_01/id_6/NOTE.md
@@ -4,4 +4,8 @@
在平时的工作之中,自己会刻意地去想有没有更好、更优化的解决方案,这个业务的时间复杂度是多少、空间复杂度是多少,有没有更加优化的解决方案,可以减少内存占用或者服务器资源占用,自己会更多地去思考这方面的问题,这对于自己的平时工作也是一个很的提升。
-本周联系的题目不算多,但是自己对于每一个题目的思考有很多,不只是每道题目的解法算法,还有不同的思路,自己选择的算法与数据结构,开拓了自己从前没有思考过的思维,并且能够把这种思维应用到实际的业务和场景中,这是自己最大的收获。
\ No newline at end of file
+本周联系的题目不算多,但是自己对于每一个题目的思考有很多,不只是每道题目的解法算法,还有不同的思路,自己选择的算法与数据结构,开拓了自己从前没有思考过的思维,并且能够把这种思维应用到实际的业务和场景中,这是自己最大的收获。
+
+
+
+# 脑图做得非常好!总结也很不错。继续保持下去!
diff --git "a/Week_01/id_7/\346\225\260\346\215\256\347\273\223\346\236\204\344\270\216\347\256\227\346\263\225\345\217\212\345\255\246\344\271\240\346\226\271\346\263\225.png" "b/Week_01/id_7/\346\225\260\346\215\256\347\273\223\346\236\204\344\270\216\347\256\227\346\263\225\345\217\212\345\255\246\344\271\240\346\226\271\346\263\225.png"
new file mode 100644
index 00000000..f5f774a8
Binary files /dev/null and "b/Week_01/id_7/\346\225\260\346\215\256\347\273\223\346\236\204\344\270\216\347\256\227\346\263\225\345\217\212\345\255\246\344\271\240\346\226\271\346\263\225.png" differ
diff --git a/Week_01/id_8/NOTE.md b/Week_01/id_8/NOTE.md
index bee89292..04025785 100644
--- a/Week_01/id_8/NOTE.md
+++ b/Week_01/id_8/NOTE.md
@@ -68,3 +68,5 @@ class Solution {
}
}
```
+
+Chao:非常好的总结;注意使用这样的办法继续保持训练下去。
\ No newline at end of file
diff --git a/Week_01/id_9/LeetCode_50_9.java b/Week_01/id_9/LeetCode_50_9.java
index 850ff8d9..2a814f34 100644
--- a/Week_01/id_9/LeetCode_50_9.java
+++ b/Week_01/id_9/LeetCode_50_9.java
@@ -35,6 +35,7 @@ public double halfPow(double x, int n) {
double temp = halfPow(x, n / 2);
+ // 优化三目,直接return
if (flag) {
result = temp * temp;
} else {
diff --git a/Week_02/.idea/Week_02.iml b/Week_02/.idea/Week_02.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/Week_02/.idea/Week_02.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_02/.idea/encodings.xml b/Week_02/.idea/encodings.xml
new file mode 100644
index 00000000..15a15b21
--- /dev/null
+++ b/Week_02/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Week_02/.idea/misc.xml b/Week_02/.idea/misc.xml
new file mode 100644
index 00000000..28a804d8
--- /dev/null
+++ b/Week_02/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_02/.idea/modules.xml b/Week_02/.idea/modules.xml
new file mode 100644
index 00000000..c0a6a7ae
--- /dev/null
+++ b/Week_02/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_02/.idea/vcs.xml b/Week_02/.idea/vcs.xml
new file mode 100644
index 00000000..6c0b8635
--- /dev/null
+++ b/Week_02/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_02/.idea/workspace.xml b/Week_02/.idea/workspace.xml
new file mode 100644
index 00000000..257bebd1
--- /dev/null
+++ b/Week_02/.idea/workspace.xml
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1560681524748
+
+
+ 1560681524748
+
+
+
+ 1560682106400
+
+
+
+ 1560682106400
+
+
+ 1560682222777
+
+
+
+ 1560682222778
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week_02/id_11/LeetCode_111_11.js b/Week_02/id_11/LeetCode_111_11.js
new file mode 100644
index 00000000..6f858300
--- /dev/null
+++ b/Week_02/id_11/LeetCode_111_11.js
@@ -0,0 +1,23 @@
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @return {number}
+ */
+var minDepth = function(root) {
+ if(root == null) return 0
+
+ let left = minDepth(root.left)
+ let right = minDepth(root.right)
+ if(left == 0 || right == 0){
+ return Math.max(left, right) + 1
+ }
+ else{
+ return Math.min(left, right) + 1
+ }
+};
\ No newline at end of file
diff --git a/Week_02/id_11/LeetCode_1_11.js b/Week_02/id_11/LeetCode_1_11.js
new file mode 100644
index 00000000..eb06a231
--- /dev/null
+++ b/Week_02/id_11/LeetCode_1_11.js
@@ -0,0 +1,19 @@
+/**
+ * @param {number[]} nums
+ * @param {number} target
+ * @return {number[]}
+ */
+var twoSum = function(nums, target) {
+
+ let map = {}
+ for(let i = nums.length - 1; i>=0; i--){
+ let value = target - nums[i]
+ if(map[value] != null){
+ return [i, map[value]]
+ }
+ map[nums[i]] = i
+ }
+
+ return []
+};
+
diff --git a/Week_02/id_11/LeetCode_783_11.js b/Week_02/id_11/LeetCode_783_11.js
new file mode 100644
index 00000000..917d64f3
--- /dev/null
+++ b/Week_02/id_11/LeetCode_783_11.js
@@ -0,0 +1,27 @@
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @return {number}
+ */
+
+var minDiffInBST = function(root) {
+ let pre
+ let min = 100
+
+ var inOrder = root => {
+ if (root.left != null) inOrder(root.left);
+ if (pre != null) min = Math.min(min, root.val - pre);
+ pre = root.val;
+ if (root.right != null) inOrder(root.right);
+ return min;
+ }
+
+ return inOrder(root)
+};
+
diff --git a/Week_02/id_16/Map b/Week_02/id_16/Map
new file mode 100644
index 00000000..9be128fe
--- /dev/null
+++ b/Week_02/id_16/Map
@@ -0,0 +1,62 @@
+//692 前K个高频词
+import java.awt.List;
+import java.util.*;
+import java.util.ArrayList;
+
+public class Main {
+
+ public ArrayList topKFrequent(String[] words, int k) {
+ HashMap map = new HashMap<>();
+
+ for (String word : words) {
+ map.put(word, map.getOrDefault(word, 0) + 1);
+ }
+
+ PriorityQueue queue = new PriorityQueue<>(k, new Comparator() {
+ @Override
+ public int compare(String s1, String s2) {
+ if (map.get(s1).equals(map.get(s2))) {
+ return s2.compareTo(s1);
+ }
+ return map.get(s1).compareTo(map.get(s2));
+
+ }
+ });
+
+ for (String key : map.keySet()) {
+ if (queue.size() < k) {
+ queue.add(key);
+ } else if (queue.comparator().compare(key, queue.peek()) > 0) {
+ queue.poll();
+ queue.add(key);
+ }
+ }
+
+ String[] res = new String[k];
+
+ for (int i = k - 1; i >= 0; i--) {
+ res[i] = queue.poll();
+ }
+
+ return (ArrayList) Arrays.asList(res);
+
+ }
+
+
+
+
+
+ public static void main(String[] args)
+ {
+ String s="abc";
+ String c="vrd";
+ Main v=new Main();
+ //System.out.println(v.sea(s,c));
+ String q="abc";
+ String n="ccccccccc";
+ System.out.println(v.lengthOfLongestSubstring(q));
+ System.out.println(v.lengthOfLongestSubstring(n));
+
+ }
+
+}
diff --git a/Week_02/id_16/Map1 b/Week_02/id_16/Map1
new file mode 100644
index 00000000..84e464a6
--- /dev/null
+++ b/Week_02/id_16/Map1
@@ -0,0 +1,15 @@
+ //242 有效的字母异位
+ 字符串数组是否元素相同
+
+ public boolean sea(String s,String t)
+ {
+ char []schars=s.toCharArray();
+ char []tchars=t.toCharArray();
+ Arrays.sort(schars);
+ Arrays.sort(tchars);
+ if(schars==tchars)
+ return true;
+ else
+ return false;
+
+ }
\ No newline at end of file
diff --git a/Week_02/id_16/Map2 b/Week_02/id_16/Map2
new file mode 100644
index 00000000..02925a13
--- /dev/null
+++ b/Week_02/id_16/Map2
@@ -0,0 +1,14 @@
+ //3
+ public int lengthOfLongestSubstring(String s) {
+ int n=s.length();
+ if(n<=1) return n;
+ int max=1;
+ for(int i=0;i set=new HashSet<>();
+ for(int j=i;j= 0) {
+ return [hashTable[other], i];
+ };
+ hashTable[nums[i]] = i;
+ }
+ return null;
+};
\ No newline at end of file
diff --git a/Week_02/id_39/LeetCode_242_39.js b/Week_02/id_39/LeetCode_242_39.js
new file mode 100644
index 00000000..559310ef
--- /dev/null
+++ b/Week_02/id_39/LeetCode_242_39.js
@@ -0,0 +1,30 @@
+/**
+ * @param {string} s
+ * @param {string} t
+ * @return {boolean}
+ * https://leetcode.com/problems/valid-anagram/
+ */
+var isAnagram = function(s, t) {
+ if (s.length !== t.length) {
+ return false;
+ }
+ let sArr = s.split('');
+ let tArr = t.split('');
+ let map = {};
+
+ for (let i = 0; i < sArr.length; i++) {
+ if (!map[sArr[i]]) {
+ map[sArr[i]] = 1;
+ } else {
+ map[sArr[i]]++;
+ }
+ }
+
+ for (let i = 0; i < tArr.length; i++) {
+ if (!map[tArr[i]] || map[tArr[i]] <= 0) {
+ return false;
+ }
+ map[tArr[i]]--;
+ }
+ return true;
+};
\ No newline at end of file
diff --git a/Week_02/id_39/LeetCode_3_39.js b/Week_02/id_39/LeetCode_3_39.js
new file mode 100644
index 00000000..b662e914
--- /dev/null
+++ b/Week_02/id_39/LeetCode_3_39.js
@@ -0,0 +1,20 @@
+/**
+ * @param {string} s
+ * @return {number}
+ * https://leetcode.com/problems/longest-substring-without-repeating-characters/
+ */
+var lengthOfLongestSubstring = function(s) {
+ let sArr = s.split('');
+ let max = 0;
+ let map = {};
+ let left = 0;
+ for (let i = 0; i < sArr.length; i++) {
+ if (map[sArr[i]] != null) {
+ left = Math.max(left, map[sArr[i]] + 1);
+ }
+ map[sArr[i]] = i;
+ max = Math.max(max, i - left + 1);
+ }
+
+ return max;
+};
\ No newline at end of file
diff --git a/Week_03/id_11/LeetCode_103_11.js b/Week_03/id_11/LeetCode_103_11.js
new file mode 100644
index 00000000..6d32a6c5
--- /dev/null
+++ b/Week_03/id_11/LeetCode_103_11.js
@@ -0,0 +1,40 @@
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @return {number[][]}
+ */
+var zigzagLevelOrder = function(root) {
+
+ let list = []
+ let level = 0
+
+ bfs(root, level, list)
+
+ return list
+};
+
+var bfs = function(root, level, list){
+ if(root == null) return
+
+ if(list[level] == null){
+ list[level] = []
+ }
+
+ if((level & 1) != 0){
+ list[level].push(root.val)
+ }
+ else{
+ list[level].shift(root.val)
+ }
+
+
+ bfs(root.left, level + 1, list)
+ bfs(root.right, level + 1, list)
+}
+
diff --git a/Week_03/id_11/LeetCode_104_11.js b/Week_03/id_11/LeetCode_104_11.js
new file mode 100644
index 00000000..e1392d53
--- /dev/null
+++ b/Week_03/id_11/LeetCode_104_11.js
@@ -0,0 +1,29 @@
+/**
+ * Definition for a binary tree node.
+ * function TreeNode(val) {
+ * this.val = val;
+ * this.left = this.right = null;
+ * }
+ */
+/**
+ * @param {TreeNode} root
+ * @return {number}
+ */
+var maxDepth = function(root) {
+ let max = 0
+ let level = 0
+
+ dfs(root, level, max)
+ return max
+};
+
+
+var dfs = function(root, level, max){
+
+ if(root == null) return
+ if(level > max){
+ max = level
+ }
+ dfs(root.left, level + 1, max)
+ dfs(root.right, level + 1, max)
+}
diff --git a/Week_03/id_11/LeetCode_429_11.js b/Week_03/id_11/LeetCode_429_11.js
new file mode 100644
index 00000000..ab0816b4
--- /dev/null
+++ b/Week_03/id_11/LeetCode_429_11.js
@@ -0,0 +1,38 @@
+/**
+ * // Definition for a Node.
+ * function Node(val,children) {
+ * this.val = val;
+ * this.children = children;
+ * };
+ */
+/**
+ * @param {Node} root
+ * @return {number[][]}
+ */
+var levelOrder = function(root) {
+
+ let list = []
+ let level = 0
+
+ bfs(root, level, list)
+
+ return list
+};
+
+var bfs = function(root, level, list){
+ if(root == null) return
+
+ if(list[level] == null){
+ list[level] = []
+ }
+
+ list[level].push(root.val)
+
+ root.children.forEach(child =>{
+ bfs(child, level + 1, list)
+ })
+}
+
+let root = {"$id":"1","children":[{"$id":"2","children":[{"$id":"5","children":[],"val":5},{"$id":"6","children":[],"val":6}],"val":3},{"$id":"3","children":[],"val":2},{"$id":"4","children":[],"val":4}],"val":1}
+
+console.log(levelOrder(root));
diff --git a/Week_03/id_19/LeetCode_200_19.java b/Week_03/id_19/LeetCode_200_19.java
new file mode 100644
index 00000000..e3c5e1f8
--- /dev/null
+++ b/Week_03/id_19/LeetCode_200_19.java
@@ -0,0 +1,26 @@
+class Solution {
+ public int numIslands(char[][] grid) {
+ if( grid == null || grid.length == 0 ) return 0;
+ int res = 0;
+ for(int i = 0;i < grid.length;i++)
+ for(int j = 0;j < grid[0].length;j++)
+ if(grid[i][j] == '1') {
+ dfs(i,j,grid);
+ res++;
+ }
+ return res;
+ }
+
+ public void dfs(int i,int j,char[][] grid){
+ if(i < 0 || i >= grid.length) return;
+ if(j < 0 || j >= grid[0].length) return;
+ if(grid[i][j] == '0') return;
+
+ grid[i][j] = '0';
+
+ dfs(i,j+1,grid);
+ dfs(i,j-1,grid);
+ dfs(i+1,j,grid);
+ dfs(i-1,j,grid);
+ }
+}
\ No newline at end of file
diff --git a/Week_03/id_19/LeetCode_210_19.java b/Week_03/id_19/LeetCode_210_19.java
new file mode 100644
index 00000000..bc76a958
--- /dev/null
+++ b/Week_03/id_19/LeetCode_210_19.java
@@ -0,0 +1,73 @@
+class Solution {
+ static int WHITE = 1;
+ static int GRAY = 2;
+ static int BLACK = 3;
+
+ private Map color;
+ private Map> adjList;
+ private List topologicalOrder;
+
+ private boolean isPossible;
+
+ private void init(int num){
+ this.color = new HashMap();
+ this.adjList = new HashMap>();
+ this.topologicalOrder = new ArrayList();
+
+ this.isPossible = true;
+
+ for(int i = 0; i < num; i++) {
+ this.color.put(i,WHITE);
+ }
+ }
+ private void dfs(int node) {
+ if(!this.isPossible)
+ return;
+ if(this.color.get(node) == BLACK)
+ return;
+ if(this.color.get(node) == GRAY) {
+ isPossible = false;
+ return;
+ }
+
+ this.color.put(node,GRAY);
+
+ for(Integer next : this.adjList.getOrDefault(node,new ArrayList())) {
+ this.dfs(next);
+ }
+
+ this.color.put(node,BLACK);
+ this.topologicalOrder.add(node);
+
+ }
+ public int[] findOrder(int numCourses, int[][] prerequisites) {
+
+ this.init(numCourses);
+
+ for(int i = 0;i < prerequisites.length; i++) {
+ int dest = prerequisites[i][0];
+ int src = prerequisites[i][1];
+
+ List list = this.adjList.getOrDefault(src,new ArrayList());
+
+ list.add(dest);
+
+ this.adjList.put(src,list);
+ }
+
+ for(int i = 0; i < numCourses; i++) {
+ if(this.color.get(i) == WHITE)
+ dfs(i);
+ }
+
+ if(!this.isPossible) {
+ return new int[0];
+ } else {
+ int[] res = new int[numCourses];
+ for(int i = 0; i < numCourses; i++) {
+ res[i] = this.topologicalOrder.get(numCourses-i-1);
+ }
+ return res;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week_03/id_3/dfs/LeetCode_127_3_v2.py b/Week_03/id_3/dfs/LeetCode_127_3_v2.py
index 015004ba..d3f5c926 100644
--- a/Week_03/id_3/dfs/LeetCode_127_3_v2.py
+++ b/Week_03/id_3/dfs/LeetCode_127_3_v2.py
@@ -22,9 +22,7 @@ def ladderLength(self, begin, end, word_list) -> int:
begin_queue = [begin]
end_queue = [end]
- while True:
- if not begin_queue and not end_queue:
- return 0
+ while begin_queue or end_queue:
if count % 2 == 0:
queue = begin_queue
cur_set, target_set = begin_set, end_set
@@ -56,6 +54,6 @@ def ladderLength(self, begin, end, word_list) -> int:
s = Solution()
-# print(s.ladderLength("hit", "cog", ["hot", "dot", "dog", "lot", "log", "cog"]))
-# print(s.ladderLength("hit", "cog", ["hot", "dot", "dog", "lot"]))
+print(s.ladderLength("hit", "cog", ["hot", "dot", "dog", "lot", "log", "cog"]))
+print(s.ladderLength("hit", "cog", ["hot", "dot", "dog", "lot"]))
print(s.ladderLength("hot", "dog", ["hot", "dog"]))
diff --git a/Week_03/id_7/LeetCode_295_7.cs b/Week_03/id_7/LeetCode_295_7.cs
new file mode 100644
index 00000000..7198f467
--- /dev/null
+++ b/Week_03/id_7/LeetCode_295_7.cs
@@ -0,0 +1,147 @@
+/*
+ * @lc app=leetcode.cn id=295 lang=csharp
+ *
+ * [295] 数据流的中位数
+ */
+using System.Collections.Generic;
+
+// 方法1:暴力法,每插入一个数,就排序整个序列,一般排序时间复杂度为O(nlogn),取中位数为O(1),所以总的来说是O(nlogn)
+// 这里就不写了,实测提交会超时
+
+// 方法2:使用插入排序,插入排序的时间复杂度为O(logn),需要添加的n个数的话,遍历造成的时间复杂度为O(n),所以总的来说是O(n)
+// public class MedianFinder1 {
+
+// private List m_lst;
+// /** initialize your data structure here. */
+// public MedianFinder1 () {
+// m_lst = new List ();
+// }
+
+// public void AddNum (int num) {
+// if (m_lst.Count == 0) {
+// m_lst.Add (num);
+// return;
+// }
+// m_lst.Insert (GetMedianIndex (0, m_lst.Count, num), num);
+// }
+
+// public int GetMedianIndex (int start, int end, int num) {
+// if (start == end) {
+// return start;
+// }
+// int mid = (end - start) / 2 + start;
+// if (m_lst[mid] > num) {
+// return GetMedianIndex (start, mid, num);
+// } else if (m_lst[mid] < num) {
+// return GetMedianIndex (mid + 1, end, num);
+// } else {
+// return mid;
+// }
+// }
+
+// public double FindMedian () {
+// if (m_lst.Count == 1) {
+// return m_lst[0];
+// }
+// if (m_lst.Count % 2 == 1) {
+// return m_lst[m_lst.Count / 2];
+// } else {
+// return (double) (m_lst[m_lst.Count / 2 - 1] + m_lst[m_lst.Count / 2]) / 2;
+// }
+// }
+// }
+
+// 方法3:两个优先队列(自己使用sortedlist实现,效率不如二分法),一个降序,一个升序
+public class MedianFinder {
+
+ PriorityQueue pqo = new PriorityQueue (true);
+ PriorityQueue pqi = new PriorityQueue ();
+
+ /** initialize your data structure here. */
+ public MedianFinder () { }
+
+ public void AddNum (int num) {
+ pqo.Enqueue (num);
+
+ pqi.Enqueue (pqo.Dequeue ());
+
+ if (pqo.Size () < pqi.Size ()) {
+ pqo.Enqueue (pqi.Dequeue ());
+ }
+ }
+
+ public double FindMedian () {
+ return pqo.Size () > pqi.Size () ? (double) pqo.Top () : (pqo.Top () + pqi.Top ()) * 0.5;
+ }
+}
+
+class DescendedDateComparer : IComparer {
+ public int Compare (int x, int y) {
+ // use the default comparer to do the original comparison for int
+ int ascendingResult = Comparer.Default.Compare (x, y);
+
+ // turn the result around
+ return 0 - ascendingResult;
+ }
+}
+
+public class PriorityQueue {
+ private SortedList m_sortedlst;
+ private int m_nCount;
+
+ public PriorityQueue (bool blDescending = false) {
+ if (blDescending) {
+ m_sortedlst = new SortedList (new DescendedDateComparer ());
+ } else {
+ m_sortedlst = new SortedList ();
+ }
+ m_nCount = 0;
+ }
+
+ public void Enqueue (int num) {
+ if (m_sortedlst.ContainsKey (num)) {
+ m_sortedlst[num]++;
+ } else {
+ m_sortedlst.Add (num, 1);
+ }
+ m_nCount++;
+ }
+
+ public int Dequeue () {
+
+ if (m_nCount == 0) {
+ return 0;
+ }
+
+ int ans = m_sortedlst.Keys[0];
+
+ if (m_sortedlst.GetValueOrDefault (ans) > 1) {
+ m_sortedlst[ans] = m_sortedlst.Values[0] - 1;
+ } else {
+ m_sortedlst.Remove (ans);
+ }
+
+ m_nCount--;
+
+ return ans;
+ }
+
+ public int Top () {
+ if (m_nCount == 0) {
+ return 0;
+ }
+
+ return m_sortedlst.Keys[0];
+ }
+
+ public int Size () {
+ return m_nCount;
+ }
+}
+
+/**
+ * Your MedianFinder object will be instantiated and called as such:
+ * MedianFinder obj = new MedianFinder();
+ * obj.AddNum(num);
+ * double param_2 = obj.FindMedian();
+ */
\ No newline at end of file
diff --git "a/Week_03/id_7/703.\346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254k\345\244\247\345\205\203\347\264\240.cs" b/Week_03/id_7/LeetCode_703_7.cs
similarity index 65%
rename from "Week_03/id_7/703.\346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254k\345\244\247\345\205\203\347\264\240.cs"
rename to Week_03/id_7/LeetCode_703_7.cs
index 54b1c54a..55dd4f22 100644
--- "a/Week_03/id_7/703.\346\225\260\346\215\256\346\265\201\344\270\255\347\232\204\347\254\254k\345\244\247\345\205\203\347\264\240.cs"
+++ b/Week_03/id_7/LeetCode_703_7.cs
@@ -7,11 +7,13 @@
public class KthLargest {
int[] heap;
+ // 堆中已经存储的数据个数
int count;
+ // 堆容量
int capacity;
public KthLargest (int k, int[] nums) {
- heap = new int[nums.Length];
+ heap = new int[k];
capacity = k;
count = 0;
for (int i = 0; i < nums.Length; i++) {
@@ -21,16 +23,18 @@ public KthLargest (int k, int[] nums) {
public int Add (int val) {
if (count < capacity) {
- heap[count++] = val;
- int i = count - 1;
+ heap[count] = val;
+ int i = count;
while (i > 0) {
- if (heap[i] < heap[(i - 1) / 2]) {
+ int nPIndex = (i - 1) / 2;
+ if (heap[i] < heap[nPIndex]) {
int temp = heap[i];
- heap[i] = heap[(i - 1) / 2];
- heap[(i - 1) / 2] = temp;
+ heap[i] = heap[nPIndex];
+ heap[nPIndex] = temp;
}
- i = (i - 1) / 2;
+ i = nPIndex;
}
+ count++;
} else if (val > heap[0]) {
heap[0] = val;
int i = 0;
@@ -39,9 +43,10 @@ public int Add (int val) {
if (i + 1 < count && heap[i] > heap[i + 1]) {
i++;
}
- if (heap[(i - 1) / 2] > heap[i]) {
- int temp = heap[(i - 1) / 2];
- heap[(i - 1) / 2] = heap[i];
+ int nPIndex = (i - 1) / 2;
+ if (heap[nPIndex] > heap[i]) {
+ int temp = heap[nPIndex];
+ heap[nPIndex] = heap[i];
heap[i] = temp;
}
}
diff --git a/Week_03/id_9/LeetCode_104_9.java b/Week_03/id_9/LeetCode_104_9.java
new file mode 100644
index 00000000..848cacd9
--- /dev/null
+++ b/Week_03/id_9/LeetCode_104_9.java
@@ -0,0 +1,39 @@
+package com.github.lifelab.leetcode.problemset;
+
+/**
+ * 二叉树的最大深度 @https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/
+ *
+ * @author Weichao Li (liweichao0102@gmail.com)
+ * @since 2019-06-09
+ */
+public class Solution104 {
+
+ public int maxDepth(TreeNode root) {
+ return depth(root, 0);
+ }
+
+ private int depth(TreeNode node, int depth) {
+
+ if (node == null) {
+ return 0;
+ }
+
+ depth++;
+
+ if (node.left == null && node.right == null) {
+ return depth;
+ }
+
+ int l = 0, r = 0;
+
+ if (node.left != null) {
+ l = depth(node.left, depth);
+ }
+
+ if (node.right != null) {
+ r = depth(node.right, depth);
+ }
+
+ return Math.max(l, r);
+ }
+}
diff --git a/Week_03/id_9/LeetCode_111_9.java b/Week_03/id_9/LeetCode_111_9.java
new file mode 100644
index 00000000..a63dea9b
--- /dev/null
+++ b/Week_03/id_9/LeetCode_111_9.java
@@ -0,0 +1,40 @@
+package com.github.lifelab.leetcode.problemset;
+
+import java.util.Objects;
+
+/**
+ * 二叉树的最小深度 @see https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/submissions/
+ *
+ * @author Weichao Li (liweichao0102@gmail.com)
+ * @since 2019-07-07
+ */
+public class Solution111 {
+
+ public int minDepth(TreeNode root) {
+ return minDepth(root, 0);
+ }
+
+ public int minDepth(TreeNode node, int currentDepth) {
+
+ if (node == null) {
+ return currentDepth;
+ }
+
+ currentDepth++;
+
+ if (Objects.isNull(node.left) && Objects.isNull(node.right)) {
+ return currentDepth;
+ } else {
+
+ int minDepth = Integer.MAX_VALUE;
+ if (node.left != null) {
+ minDepth = Math.min(minDepth(node.left, currentDepth), minDepth);
+ }
+ if (node.right != null) {
+ minDepth = Math.min(minDepth(node.right, currentDepth), minDepth);
+ }
+ return minDepth;
+ }
+
+ }
+}
diff --git a/Week_03/id_9/LeetCode_547_9.java b/Week_03/id_9/LeetCode_547_9.java
new file mode 100644
index 00000000..71182461
--- /dev/null
+++ b/Week_03/id_9/LeetCode_547_9.java
@@ -0,0 +1,50 @@
+package com.github.lifelab.leetcode.problemset;
+
+/**
+ * 朋友圈 @https://leetcode-cn.com/problems/friend-circles/
+ *
+ * @author Weichao Li (liweichao0102@gmail.com)
+ * @since 2019-07-07
+ */
+public class Solution547 {
+
+
+ public int findCircleNum(int[][] M) {
+ //二维数组长度,即所有人的个数
+ int length = M.length;
+ //统计朋友圈个数
+ int count = 0;
+ //访问标志
+ boolean[] flag = new boolean[length];
+ //对于每个人
+ for (int i = 0; i < length; i++) {
+ //如果未被访问
+ if (!flag[i]) {
+ //深度优先搜索,访问
+ dfs(i, M, flag);
+ //朋友圈个数+1
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * 深度优先搜索
+ *
+ * @param i 人的位置
+ * @param M 朋友圈
+ * @param flag 访问标识
+ */
+ public void dfs(int i, int[][] M, boolean[] flag) {
+ //当前位占位
+ flag[i] = true;
+
+ for (int j = 0; j < M[i].length; j++) {
+
+ if (!flag[j] && M[i][j] == 1) {
+ dfs(j, M, flag);
+ }
+ }
+ }
+}
diff --git a/Week_04/id_11/LeetCode_169_11.js b/Week_04/id_11/LeetCode_169_11.js
index e2299e27..c7e9c02a 100644
--- a/Week_04/id_11/LeetCode_169_11.js
+++ b/Week_04/id_11/LeetCode_169_11.js
@@ -3,18 +3,17 @@
* @return {number}
*/
var majorityElement = function(nums) {
-
+
if(nums.length == 1){
return nums[0]
}
-
+
let maj = {}
- let majNum
+ let majNum
nums.forEach(num => {
if(maj[num] == null){
maj[num] = 1
- }
- else{
+ } else {
maj[num] = maj[num] + 1
if(maj[num] > nums.length/2){
majNum = num
@@ -22,7 +21,7 @@ var majorityElement = function(nums) {
}
}
})
-
+
return majNum
-
+
};
\ No newline at end of file
diff --git a/Week_04/id_11/LeetCode_70_11.js b/Week_04/id_11/LeetCode_70_11.js
index aeb9bafd..c34094de 100644
--- a/Week_04/id_11/LeetCode_70_11.js
+++ b/Week_04/id_11/LeetCode_70_11.js
@@ -3,12 +3,13 @@
* @return {number}
*/
var climbStairs = function(n) {
-
- let s = []
+
if(n == 0) return 1
if(n == 1) return 1
+
+ let s = []
s[0] = 1
s[1] = 1
for(let i = 2; i<= n; i++){
diff --git a/Week_04/id_19/LeetCode_169_19.java b/Week_04/id_19/LeetCode_169_19.java
new file mode 100644
index 00000000..e69de29b
diff --git a/Week_04/id_19/LeetCode_720_19.java b/Week_04/id_19/LeetCode_720_19.java
new file mode 100644
index 00000000..c7a23d4b
--- /dev/null
+++ b/Week_04/id_19/LeetCode_720_19.java
@@ -0,0 +1,59 @@
+class Solution {
+ private static final int R=26;
+ private TrieNode root;
+
+ private class TrieNode {
+ TrieNode[] children;
+ String word;
+
+ public TrieNode() {
+ children = new TrieNode[R];
+ word = null;
+ }
+ }
+
+ public void insertWord(String word) {
+ int len = word.length();
+ TrieNode curr = root;
+ int index;
+ char c;
+ for(int i=0;i len) {
+ res = s;
+ len = s.length();
+ }
+
+ }
+
+ return res;
+ }
+
+ public String longestWord(String[] words) {
+ root = new TrieNode();
+
+ for(String word : words) {
+ insertWord(word);
+ }
+
+ return findLongestWord(root);
+ }
+}
\ No newline at end of file
diff --git "a/Week_04/id_2/\347\254\254\345\233\233\345\221\250\346\200\273\347\273\223.md" "b/Week_04/id_2/\347\254\254\345\233\233\345\221\250\346\200\273\347\273\223.md"
index b50c82b2..b0ad7b8a 100644
--- "a/Week_04/id_2/\347\254\254\345\233\233\345\221\250\346\200\273\347\273\223.md"
+++ "b/Week_04/id_2/\347\254\254\345\233\233\345\221\250\346\200\273\347\273\223.md"
@@ -2,7 +2,7 @@
第四周基本上题目类型都属于比较难的,所以我从简单题目开始刷起。
720:快速写完,代码量有点多,实现了一个修改版的trie,为什么说是修改版,因为我对传进来的word数组进行了排序,所以后面的单词肯定包含前面的单词。那我就进行个排序将前面的单词先build。
70:快速使用三种方法写完,一个回溯,一个递推,一个dp。然后把使用递归的方法通过加备忘录的方式优化了时间复杂度和空间复杂度。降低到和dp一样的O(n)。
-198:快速写完,后来看了discussion,人家进一步降低了空间复杂度,用了两个变量prev1,和prev2来代表max(n-1)和max(n-2),将空间复杂度降低为O(1)。值得学习。
+198:快速写完,后来看了discuss,人家进一步降低了空间复杂度,用了两个变量prev1,和prev2来代表max(n-1)和max(n-2),将空间复杂度降低为O(1)。值得学习。
309:参考了reference,难点是动态转移方程的建立,这道题用到了两个动态转移数组,比较难想到,也算一种题型和思路,下次碰到类似提醒,可以想想多种状态,每种状态也有时间顺序变化,状态之间又互相影响,可以通过使用不同的动态转移数组来表示。
213:是198的变形,快速写完,但是我的代码不够简洁,我将其分为0-n-2和1-n-1两段,然后取其最大值。
62:这道题印象太深刻了,我面试的时候遇到过,直接DP写出,当然也可以用回溯用递推,很多种方法,dp是最好的方法。我面试的时候做出来了吗,答案是我做出来了,我用了两种回溯和DP,不过DP的递推公式是面试官提示的。
diff --git a/Week_04/id_24/LeetCode_455_024.py b/Week_04/id_24/LeetCode_455_024.py
index cb264eda..deff1bdf 100644
--- a/Week_04/id_24/LeetCode_455_024.py
+++ b/Week_04/id_24/LeetCode_455_024.py
@@ -5,7 +5,7 @@ def findContentChildren(self, g, s):
:type s: List[int]
:rtype: int
"""
- childs = 0
+ childs = 0 # 注意:复数是 children
cookies = 0
g.sort()
s.sort()
diff --git a/Week_04/id_3/backtracking/LeetCode_46_3_v1.py b/Week_04/id_3/backtracking/LeetCode_46_3_v1.py
new file mode 100644
index 00000000..4bda7a7b
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_46_3_v1.py
@@ -0,0 +1,31 @@
+"""
+全排列 O(n^n) 似乎没啥悬念
+====== 但是我居然没通过
+两点问题
+1 递归的退出条件不能忘了return
+2 set在迭代到时候要小心插入和删除,还是list复制一份更为稳妥
+"""
+
+
+class Solution:
+ def permute(self, nums):
+ results = []
+ if not nums:
+ return results
+ self.recursion([], set(nums), results)
+ return results
+
+ def recursion(self, curr, num_set, results):
+ if len(num_set) == 0:
+ results.append(curr)
+ return
+
+ for n in list(num_set):
+ num_set.remove(n)
+ self.recursion(curr + [n], num_set, results)
+ num_set.add(n)
+
+
+s = Solution()
+print(s.permute([1, 2, 3]))
+print(s.permute([6, 2, -1, 8]))
diff --git a/Week_04/id_3/backtracking/LeetCode_51_3.py b/Week_04/id_3/backtracking/LeetCode_51_3.py
new file mode 100644
index 00000000..883945a4
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_51_3.py
@@ -0,0 +1,45 @@
+"""
+最原始回溯解决n皇后方法
+每一行判断是否可行,对角线方向用set可以简易实现
+"""
+
+
+class Solution:
+ def solveNQueens(self, n):
+ results = []
+ if n == 0:
+ return []
+ self.recursion(n, [], [0]*n, set(), set(), results)
+ return results
+
+ def recursion(self, n, curr, dis_col, dis_pie, dis_na, results):
+ row = len(curr) - 1
+ if n == (row + 1):
+ results.append(curr)
+ return
+ for i in range(n):
+ if dis_col[i] == 1:
+ continue
+ pie = i + row
+ if pie in dis_pie:
+ continue
+ na = i - row
+ if na in dis_na:
+ continue
+
+ line = ['.'] * n
+ line[i] = 'Q'
+
+ dis_col[i] = 1
+ dis_pie.add(pie)
+ dis_na.add(na)
+
+ self.recursion(n, curr + [''.join(line)], dis_col, dis_pie, dis_na, results)
+
+ dis_col[i] = 0
+ dis_pie.remove(pie)
+ dis_na.remove(na)
+
+
+s = Solution()
+print(s.solveNQueens(4))
diff --git a/Week_04/id_3/backtracking/LeetCode_77_3_v1.py b/Week_04/id_3/backtracking/LeetCode_77_3_v1.py
new file mode 100644
index 00000000..1589cae1
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_77_3_v1.py
@@ -0,0 +1,25 @@
+"""
+全组合 避免重复元素出现
+使用下标过滤掉已经组合过的是一个常用的技巧
+"""
+
+
+class Solution:
+ def combine(self, n, k):
+ results = []
+ if n == 0:
+ return results
+ self.recursion([], 1, n+1, k, results)
+ return results
+
+ def recursion(self, curr, index, n, k, results):
+ if len(curr) == k:
+ results.append(curr)
+ return
+
+ for i in range(index, n):
+ self.recursion(curr + [i], i + 1, n, k, results)
+
+
+s = Solution()
+print(s.combine(4, 2))
diff --git a/Week_04/id_3/backtracking/LeetCode_784_3_v1.py b/Week_04/id_3/backtracking/LeetCode_784_3_v1.py
new file mode 100644
index 00000000..0ca13a4a
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_784_3_v1.py
@@ -0,0 +1,25 @@
+class Solution:
+ def letterCasePermutation(self, ss):
+ results = []
+ if not ss:
+ return results
+ self.recursion(ss, 0, [], results)
+ return results
+
+ def recursion(self, ss, i, curr_arr, results):
+ if i == len(ss):
+ results.append(''.join(curr_arr))
+ return
+
+ c = ss[i]
+ self.recursion(ss, i + 1, curr_arr + [c], results)
+ if c.isupper():
+ self.recursion(ss, i + 1, curr_arr + [c.lower()], results)
+ elif c.islower():
+ self.recursion(ss, i + 1, curr_arr + [c.upper()], results)
+
+
+s = Solution()
+print(s.letterCasePermutation('a1b2'))
+print(s.letterCasePermutation('3z4'))
+print(s.letterCasePermutation('12345'))
diff --git a/Week_04/id_3/backtracking/LeetCode_784_3_v2.py b/Week_04/id_3/backtracking/LeetCode_784_3_v2.py
new file mode 100644
index 00000000..3272efab
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_784_3_v2.py
@@ -0,0 +1,28 @@
+"""
+尝试非递归解决
+"""
+
+
+class Solution:
+ def letterCasePermutation(self, ss):
+ if not ss:
+ return []
+
+ results = ['']
+ for c in ss:
+ _results = []
+ for r in results:
+ if c.islower() or c.isupper():
+ _results.append(r + c.upper())
+ _results.append(r + c.lower())
+ else:
+ _results.append(r + c)
+
+ results = _results
+ return results
+
+
+s = Solution()
+print(s.letterCasePermutation('a1b2'))
+print(s.letterCasePermutation('3z4'))
+print(s.letterCasePermutation('12345'))
diff --git a/Week_04/id_3/backtracking/LeetCode_78_3_v1.py b/Week_04/id_3/backtracking/LeetCode_78_3_v1.py
new file mode 100644
index 00000000..a3d47992
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_78_3_v1.py
@@ -0,0 +1,23 @@
+"""
+经典全组合
+"""
+
+
+class Solution:
+ def subsets(self, nums):
+ results = []
+ if not nums:
+ return results
+ self.recursion([], nums, results)
+ return results
+
+ def recursion(self, cur, nums, results):
+ results.append(cur)
+ if not nums:
+ return
+ for i in range(len(nums)):
+ self.recursion(cur + [nums[i]], nums[i+1:], results)
+
+
+s = Solution()
+print(s.subsets([1, 2, 3]))
diff --git a/Week_04/id_3/backtracking/LeetCode_78_3_v2.py b/Week_04/id_3/backtracking/LeetCode_78_3_v2.py
new file mode 100644
index 00000000..22033acd
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_78_3_v2.py
@@ -0,0 +1,17 @@
+"""
+经典全组合 直接调用库函数 其实为了点进去看看他的实现代码
+"""
+import itertools
+
+
+class Solution:
+ def subsets(self, nums):
+ results = []
+ for i in range(len(nums) + 1):
+ for r in itertools.combinations(nums, i):
+ results.append(list(r))
+ return results
+
+
+s = Solution()
+print(s.subsets([1, 2, 3]))
diff --git a/Week_04/id_3/backtracking/LeetCode_78_3_v3.py b/Week_04/id_3/backtracking/LeetCode_78_3_v3.py
new file mode 100644
index 00000000..66a426bb
--- /dev/null
+++ b/Week_04/id_3/backtracking/LeetCode_78_3_v3.py
@@ -0,0 +1,19 @@
+"""
+经典全组合 非递归
+"""
+import itertools
+
+
+class Solution:
+ def subsets(self, nums):
+ results = [[]]
+ for n in nums:
+ _results = []
+ for pn in results:
+ _results.append(pn + [n])
+ results += _results
+ return results
+
+
+s = Solution()
+print(s.subsets([1, 2, 3]))
diff --git a/Week_04/id_3/division/LeetCode_169_3_v1.py b/Week_04/id_3/division/LeetCode_169_3_v1.py
new file mode 100644
index 00000000..d4a598b6
--- /dev/null
+++ b/Week_04/id_3/division/LeetCode_169_3_v1.py
@@ -0,0 +1,65 @@
+"""
+既然是分治专题的,那么估计用hash的玩法是没啥意义了
+看答案 分治有点儿勉强 算是学习个思路吧
+O(nlogn)
+
+似乎分治总会比暴力要好,只要从n^2变成nlogn,如果找不到最优的O(n),那么先用nlogn也不错。
+"""
+
+
+class Solution:
+ def majorityElement(self, nums):
+ if not nums:
+ return None
+ # return self._division1(nums)
+ return self._division2(nums, 0, len(nums) - 1)
+
+ def _division1(self, nums):
+ if len(nums) == 1:
+ return nums[0]
+
+ mid = len(nums) // 2
+ left = self._division1(nums[:mid])
+ right = self._division1(nums[mid:])
+ if left == right:
+ return left
+
+ lc = 0
+ rc = 0
+ for n in nums:
+ if n == left:
+ lc += 1
+ continue
+ if n == right:
+ rc += 1
+ continue
+ return left if lc > rc else right
+
+ def _division2(self, nums, low, high):
+ if low == high:
+ return nums[low]
+
+ mid = low + (high-low)//2
+ left = self._division2(nums, low, mid)
+ right = self._division2(nums, mid+1, high)
+
+ if left == right:
+ return left
+
+ lc = 0
+ rc = 0
+ for i in range(low, high+1):
+ n = nums[i]
+ if left == n:
+ lc += 1
+ continue
+ if right == n:
+ rc += 1
+ continue
+
+ return left if lc > rc else right
+
+
+s = Solution()
+# print(s.majorityElement([2, 2, 1, 1, 1, 2, 2]))
+print(s.majorityElement([3, 3, 4]))
diff --git a/Week_04/id_3/division/LeetCode_169_3_v2.py b/Week_04/id_3/division/LeetCode_169_3_v2.py
new file mode 100644
index 00000000..c4b19801
--- /dev/null
+++ b/Week_04/id_3/division/LeetCode_169_3_v2.py
@@ -0,0 +1,23 @@
+"""
+似乎是最优解 时间O(n) 空间O(1)
+投票法
+假设一个数是众数 在遍历过程中遇到该数则投票+1,不是该数则-1。
+如果票数为0,则从新开始投票,并将下一个数设为架设众数。
+因为众数多于一半,所以最终一定会耗尽其他数的票数并最终占有票数
+"""
+
+
+class Solution:
+ def majorityElement(self, nums):
+ vote = 0
+ for n in nums:
+ if vote == 0:
+ result = n
+ vote += 1
+ continue
+ if result == n:
+ vote += 1
+ else:
+ vote -= 1
+
+ return result
diff --git a/Week_04/id_3/division/LeetCode_240_3_v1.py b/Week_04/id_3/division/LeetCode_240_3_v1.py
new file mode 100644
index 00000000..6217b09f
--- /dev/null
+++ b/Week_04/id_3/division/LeetCode_240_3_v1.py
@@ -0,0 +1,46 @@
+"""
+一时没太想到分治咋整,先按我最朴素的思路试试。
+行列都是升序,只要分别在行列中找到小于等于目标值的下标,然后访问判断即可。
+====我想错了 还是换回分治琢磨琢磨
+
+我懂了,目前的思路是,尝试把矩阵先分成2份, 先行后列,每份最大值和最小值都容易确定。然后分治并剪除不符合要求的矩阵
+"""
+
+
+class Solution:
+ def searchMatrix(self, matrix, target):
+ if not matrix or not matrix[0]:
+ return False
+ return self.division(matrix, target)
+
+ def division(self, matrix, target):
+ if not matrix or not matrix[0]:
+ return False
+
+ if matrix[0][0] == target:
+ return True
+
+ rows = len(matrix)
+ cols = len(matrix[0])
+ if matrix[0][0] > target or target > matrix[rows-1][cols-1]:
+ return False
+
+ if rows > 1:
+ index = rows//2
+ return self.division(matrix[:index], target) or self.division(matrix[index:], target)
+ else:
+ index = cols//2
+ return self.division([matrix[0][:index]], target) or self.division([matrix[0][index:]], target)
+
+
+s = Solution()
+matrix = [
+ [1, 4, 7, 11, 15],
+ [2, 5, 8, 12, 19],
+ [3, 6, 9, 16, 22],
+ [10, 13, 14, 17, 24],
+ [18, 21, 23, 26, 30]
+]
+
+print(s.searchMatrix(matrix, 5))
+print(s.searchMatrix(matrix, 20))
diff --git a/Week_04/id_3/division/LeetCode_53_3_v1.py b/Week_04/id_3/division/LeetCode_53_3_v1.py
new file mode 100644
index 00000000..f6a64d3b
--- /dev/null
+++ b/Week_04/id_3/division/LeetCode_53_3_v1.py
@@ -0,0 +1,29 @@
+"""
+额,这题分治能做吗,我还是先按朴素的想法来一下
+暴力方法最差是O(n^3)优化是O(n^2)
+
+利用经典的当前累加值,减去历史最小值的方法
+例如 [1,-2,1,2,3]
+当迭代i=4时,当前累加值5,历史最小值-1,所以最大值5-(-1)=6
+"""
+
+
+class Solution:
+ def maxSubArray(self, nums):
+ if not nums:
+ return 0
+ min_value = 0
+ result = nums[0]
+ sum_value = 0
+
+ for n in nums:
+ sum_value += n
+ result = max(result, sum_value - min_value)
+ min_value = min(sum_value, min_value)
+
+ return result
+
+
+s = Solution()
+print(s.maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]))
+print(s.maxSubArray([-1]))
diff --git a/Week_04/id_3/division/LeetCode_53_3_v2.py b/Week_04/id_3/division/LeetCode_53_3_v2.py
new file mode 100644
index 00000000..c34a384c
--- /dev/null
+++ b/Week_04/id_3/division/LeetCode_53_3_v2.py
@@ -0,0 +1,80 @@
+"""
+容我思考一下怎么分治
+======
+有点儿费劲啊
+======
+看了网上的一些答案,大体思路如下:
+如果加入限制条件,经过下标i的最大连续子数组解决就非常容易了,只需要i向两边延伸即可找到最大值。
+控制i是中间节点,则有三种情况,
+1 解包含i
+2 解在i左侧
+3 解在i右侧
+
+_max1方法是创建新数组
+_max2方法是玩弄下标
+
+反正不管怎么整,速度都不行,勉强通过
+
+时间复杂度 O(nlogn)
+"""
+
+
+class Solution:
+ def maxSubArray(self, nums):
+ if not nums:
+ return 0
+
+ # return self._max1(nums)
+ return self._max2(nums, 0, len(nums) - 1)
+
+ def _max1(self, nums):
+ if len(nums) == 1:
+ return nums[0]
+
+ if len(nums) == 2:
+ return max(nums[0], nums[1], sum(nums))
+
+ mid = len(nums) // 2
+
+ sum_value = 0
+ left_max = 0
+ for i in range(mid - 1, -1, -1):
+ sum_value += nums[i]
+ left_max = max(left_max, sum_value)
+
+ sum_value = 0
+ right_max = 0
+ for i in range(mid + 1, len(nums)):
+ sum_value += nums[i]
+ right_max = max(right_max, sum_value)
+
+ return max(nums[mid] + left_max + right_max, self._max1(nums[:mid]), self._max1(nums[mid + 1:]))
+
+ def _max2(self, nums, left, right):
+ if left == right:
+ return nums[left]
+ if (left + 1) == right:
+ return max(nums[left], nums[right], nums[left] + nums[right])
+ mid = left + (right - left) // 2
+
+ sum_value = 0
+ left_max = 0
+ for i in range(mid - 1, left-1, -1):
+ sum_value += nums[i]
+ left_max = max(left_max, sum_value)
+
+ sum_value = 0
+ right_max = 0
+ for i in range(mid + 1, right+1):
+ sum_value += nums[i]
+ right_max = max(right_max, sum_value)
+
+ return max(nums[mid] + left_max + right_max, self._max2(nums, left, mid - 1), self._max2(nums, mid + 1, right))
+
+
+s = Solution()
+print(s.maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]))
+print(s.maxSubArray([-2, 3, -1, 3, -3, 2, 1, -5, 4]))
+print(s.maxSubArray([-1]))
+print(s.maxSubArray([-2, -1]))
+print(s.maxSubArray([-2, -3, -1]))
diff --git a/Week_04/id_3/division/LeetCode_53_3_v3.py b/Week_04/id_3/division/LeetCode_53_3_v3.py
new file mode 100644
index 00000000..56b3e3d8
--- /dev/null
+++ b/Week_04/id_3/division/LeetCode_53_3_v3.py
@@ -0,0 +1,48 @@
+"""
+我想到了一个诡异的方案
+假设数组nums为解,则nums大于包含它的所有父数组,和它包含的所有子数组。
+暴力解法浪费时间之处在于累加是一个浪费时间的过程,而如果数组的和,求比之长度小1位的子数组则很容易,只需要分别减去左右两边节点即可。
+
+[1,2,3,4,5] sum=15
+[1,2,3,4] sum=15-5 [2,3,4,5] sum=15-1
+result=max(sum(nums), sum(nums[1:]...)
+
+===============================
+失败了,我真是吃饱撑的 本质上还是个O(n^2)的方案
+首次sum是n 然后减法的次数是 2+4+8+..+n 非常的尴尬
+"""
+
+
+class Solution:
+ def maxSubArray(self, nums):
+ if not nums:
+ return 0
+ return self._max2(nums, sum(nums), 0, len(nums) - 1)
+
+ def _max(self, nums, sum_value):
+ if len(nums) == 1:
+ return nums[0]
+ if len(nums) == 2:
+ return max(nums[0], nums[1], nums[0] + nums[1])
+
+ return max(sum_value,
+ self._max(nums[1:], sum_value - nums[0]),
+ self._max(nums[:-1], sum_value - nums[-1]))
+
+ def _max2(self, nums, sum_value, left, right):
+ if left == right:
+ return nums[left]
+ if len(nums) == 2:
+ return max(nums[left], nums[right], nums[left] + nums[right])
+
+ return max(sum_value,
+ self._max2(nums, sum_value - nums[left], left + 1, right),
+ self._max2(nums, sum_value - nums[right], left, right - 1))
+
+
+s = Solution()
+print(s.maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]))
+print(s.maxSubArray([-2, 3, -1, 3, -3, 2, 1, -5, 4]))
+print(s.maxSubArray([-1]))
+print(s.maxSubArray([-2, -1]))
+print(s.maxSubArray([-2, -3, -1]))
diff --git a/Week_04/id_3/dp/LeetCode_120_3_v1.py b/Week_04/id_3/dp/LeetCode_120_3_v1.py
new file mode 100644
index 00000000..53b5cfb2
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_120_3_v1.py
@@ -0,0 +1,49 @@
+"""
+给定一个三角形,找出自顶向下的最小路径和。每一步只能移动到下一行中相邻的结点上。
+
+例如,给定三角形:
+
+[
+ [2],
+ [3,4],
+ [6,5,7],
+ [4,1,8,3]
+]
+自顶向下的最小路径和为 11(即,2 + 3 + 5 + 1 = 11)。
+
+说明:
+
+如果你可以只使用 O(n) 的额外空间(n 为三角形的总行数)来解决这个问题,那么你的算法会很加分。
+================================
+递归+缓存
+"""
+
+
+class Solution:
+ def minimumTotal(self, triangle) -> int:
+ if not triangle:
+ return 0
+
+ def rec(level, idx, triangle, cache):
+ v = triangle[level][idx]
+ if level == len(triangle) - 1:
+ return v
+
+ if cache[level][idx] is None:
+ cache[level][idx] = v + min(
+ rec(level + 1, idx, triangle, cache),
+ rec(level + 1, idx + 1, triangle, cache)
+ )
+
+ return cache[level][idx]
+
+ return rec(0, 0, triangle, [[None] * len(triangle[row]) for row in range(len(triangle) - 1)])
+
+
+s = Solution()
+print(s.minimumTotal([
+ [2],
+ [3, 4],
+ [6, 5, 7],
+ [4, 1, 8, 3]
+]) == 11)
diff --git a/Week_04/id_3/dp/LeetCode_120_3_v2.py b/Week_04/id_3/dp/LeetCode_120_3_v2.py
new file mode 100644
index 00000000..a87c90b5
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_120_3_v2.py
@@ -0,0 +1,43 @@
+"""
+给定一个三角形,找出自顶向下的最小路径和。每一步只能移动到下一行中相邻的结点上。
+
+例如,给定三角形:
+
+[
+ [2],
+ [3,4],
+ [6,5,7],
+ [4,1,8,3]
+]
+自顶向下的最小路径和为 11(即,2 + 3 + 5 + 1 = 11)。
+
+说明:
+
+如果你可以只使用 O(n) 的额外空间(n 为三角形的总行数)来解决这个问题,那么你的算法会很加分。
+================================
+DP
+"""
+
+
+class Solution:
+ def minimumTotal(self, triangle) -> int:
+ if not triangle:
+ return 0
+
+ for level in range(len(triangle)-2, -1, -1):
+ current = triangle[level]
+ downstairs = triangle[level + 1]
+ for idx in range(len(current)):
+ current[idx] += min(downstairs[idx], downstairs[idx+1])
+
+ return triangle[0][0]
+
+
+s = Solution()
+print(s.minimumTotal([
+ [2],
+ [3, 4],
+ [6, 5, 7],
+ [4, 1, 8, 3]
+]) == 11)
+
diff --git a/Week_04/id_3/dp/LeetCode_188_3_v1.py b/Week_04/id_3/dp/LeetCode_188_3_v1.py
new file mode 100644
index 00000000..d7b33956
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_188_3_v1.py
@@ -0,0 +1,100 @@
+"""
+给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。
+
+设计一个算法来计算你所能获取的最大利润。你最多可以完成 k 笔交易。
+
+注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
+
+示例 1:
+
+输入: [2,4,1], k = 2
+输出: 2
+解释: 在第 1 天 (股票价格 = 2) 的时候买入,在第 2 天 (股票价格 = 4) 的时候卖出,这笔交易所能获得利润 = 4-2 = 2 。
+示例 2:
+
+输入: [3,2,6,5,0,3], k = 2
+输出: 7
+解释: 在第 2 天 (股票价格 = 2) 的时候买入,在第 3 天 (股票价格 = 6) 的时候卖出, 这笔交易所能获得利润 = 6-2 = 4 。
+ 随后,在第 5 天 (股票价格 = 0) 的时候买入,在第 6 天 (股票价格 = 3) 的时候卖出, 这笔交易所能获得利润 = 3-0 = 3 。
+
+=============================
+这个题依然是经典DP 状态编程了 天/操作状态/剩余次数
+状态 0无操作 1买入 2卖出
+先用递归暴力实现
+=============================
+这回缓存空间变大了不少 引入了k
+汗,这东西没有冻结期 状态也只需要两个 0 1
+=============================
+如果把k纳入状态空间,那么有点儿太大了
+目前的思路是用dict存储
+============================= 可惜超时了
+现在代码已经有点乱了
+尝试在查询缓存后做一些剪枝操作 如果明显目前操作次数已经多于缓存,但是当前值又很少就可以剪掉了。
+============================= 依然超时
+只能对明显k太大的部分做特殊处理了
+"""
+
+
+class Solution:
+ def maxProfit(self, k: int, prices) -> int:
+ if not k or not prices:
+ return 0
+ if k >= len(prices)//2:
+ return self.simplify(0, 0, prices, [[None, None] for _ in range(len(prices))])
+ return self.recursion(k, 0, 0, 0, prices, [[{}, {}] for _ in range(len(prices))])
+
+ def simplify(self, idx, status, prices, cache):
+ if idx >= len(prices):
+ return 0
+ if cache[idx][status] is not None:
+ return cache[idx][status]
+ next_idx = idx + 1
+ if status == 0:
+ r = max(
+ self.simplify(next_idx, 0, prices, cache),
+ self.simplify(next_idx, 1, prices, cache)
+ )
+ else:
+ r = prices[idx] - prices[idx-1] + max(
+ self.simplify(next_idx, 0, prices, cache),
+ self.simplify(next_idx, 1, prices, cache)
+ )
+ cache[idx][status] = r
+ return r
+
+ def recursion(self, k, curr, idx, status, prices, cache):
+ if idx >= len(prices) or k == -1:
+ return 0
+ tc = cache[idx][status]
+
+ if k in tc:
+ return tc[k][0]
+
+ for tk in tc.keys():
+ arr = tc[tk]
+ if k < tk and curr <= arr[1]:
+ return 0
+
+ next_idx = idx + 1
+ if status == 0:
+ r = max(
+ self.recursion(k, curr, next_idx, 0, prices, cache),
+ self.recursion(k - 1, curr, next_idx, 1, prices, cache)
+ )
+ else:
+ d = prices[idx] - prices[idx - 1]
+ next_curr = curr + d
+ r = d + max(
+ self.recursion(k, next_curr, next_idx, 0, prices, cache),
+ self.recursion(k, next_curr, next_idx, 1, prices, cache),
+ )
+ tc[k] = (r, curr)
+ return r
+
+
+s = Solution()
+print(s.maxProfit(2, [2, 1, 2, 0, 1]))
+print(s.maxProfit(2, [2, 4, 1]))
+print(s.maxProfit(2, [1, 4, 2, 7]))
+print(s.maxProfit(2, [3, 2, 6, 5, 0, 3]))
+print(s.maxProfit(2, [3, 3, 5, 0, 0, 3, 1, 4]))
diff --git a/Week_04/id_3/dp/LeetCode_188_3_v2.py b/Week_04/id_3/dp/LeetCode_188_3_v2.py
new file mode 100644
index 00000000..f72ce0fd
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_188_3_v2.py
@@ -0,0 +1,72 @@
+"""
+给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。
+
+设计一个算法来计算你所能获取的最大利润。你最多可以完成 k 笔交易。
+
+注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
+
+示例 1:
+
+输入: [2,4,1], k = 2
+输出: 2
+解释: 在第 1 天 (股票价格 = 2) 的时候买入,在第 2 天 (股票价格 = 4) 的时候卖出,这笔交易所能获得利润 = 4-2 = 2 。
+示例 2:
+
+输入: [3,2,6,5,0,3], k = 2
+输出: 7
+解释: 在第 2 天 (股票价格 = 2) 的时候买入,在第 3 天 (股票价格 = 6) 的时候卖出, 这笔交易所能获得利润 = 6-2 = 4 。
+ 随后,在第 5 天 (股票价格 = 0) 的时候买入,在第 6 天 (股票价格 = 3) 的时候卖出, 这笔交易所能获得利润 = 3-0 = 3 。
+
+=============================
+试试DP方式
+日期/操作状态/k 三个状态 O(n*k)
+=============================
+勉强通过 只打败 50% 而且没办法优雅的解决k巨大的时候 只能两种解法
+"""
+
+
+class Solution:
+ def maxProfit(self, k: int, prices) -> int:
+ if not k or not prices:
+ return 0
+
+ if k >= len(prices)//2:
+ r = 0
+ for idx in range(1, len(prices)):
+ d = prices[idx] - prices[idx - 1]
+ r = max(r, r + d)
+ return r
+
+ cache = [[0, 0], [0, 0], [0, 0]]
+ for idx in range(1, len(prices)):
+ max_k = min(idx//2 + 1, k) + 1
+ new_cache = [[0] * (k+1), [0] * (k+1), [0] * (k+1)]
+ d = prices[idx] - prices[idx-1]
+ for i in range(1, max_k):
+ # 无操作
+ new_cache[0][i] = (max(
+ cache[0][i],
+ cache[2][i],
+ ))
+
+ # 买入
+ new_cache[1][i] = (max(
+ cache[0][i - 1],
+ cache[1][i] + d,
+ cache[2][i - 1],
+ ))
+
+ # 卖出
+ new_cache[2][i] = max(cache[1][i] + d, 0)
+
+ cache = new_cache
+
+ return max(cache[0] + cache[1] + cache[2])
+
+
+s = Solution()
+print(s.maxProfit(2, [2, 1, 2, 0, 1]))
+print(s.maxProfit(2, [2, 4, 1]))
+print(s.maxProfit(2, [1, 4, 2, 7]))
+print(s.maxProfit(2, [3, 2, 6, 5, 0, 3]))
+print(s.maxProfit(2, [3, 3, 5, 0, 0, 3, 1, 4]))
diff --git a/Week_04/id_3/dp/LeetCode_188_3_v3.py b/Week_04/id_3/dp/LeetCode_188_3_v3.py
new file mode 100644
index 00000000..cd81b442
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_188_3_v3.py
@@ -0,0 +1,73 @@
+"""
+给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。
+
+设计一个算法来计算你所能获取的最大利润。你最多可以完成 k 笔交易。
+
+注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
+
+示例 1:
+
+输入: [2,4,1], k = 2
+输出: 2
+解释: 在第 1 天 (股票价格 = 2) 的时候买入,在第 2 天 (股票价格 = 4) 的时候卖出,这笔交易所能获得利润 = 4-2 = 2 。
+示例 2:
+
+输入: [3,2,6,5,0,3], k = 2
+输出: 7
+解释: 在第 2 天 (股票价格 = 2) 的时候买入,在第 3 天 (股票价格 = 6) 的时候卖出, 这笔交易所能获得利润 = 6-2 = 4 。
+ 随后,在第 5 天 (股票价格 = 0) 的时候买入,在第 6 天 (股票价格 = 3) 的时候卖出, 这笔交易所能获得利润 = 3-0 = 3 。
+
+=============================
+试试找波峰波谷的方式
+=============================
+这么做是不行的,如果是不限次数,那么没有问题,如果限制次数,这种方式就无法使用了。
+1,2,4,2,9 如果只能交易一次,那么1-9是最优解。如果可以交易2次,那么1-4,2-9是最优解。
+只能用于k>len(prices)//2的情况 而且用小顶堆优化也还没有dp的解法快
+=============================
+失败!!
+"""
+import heapq
+
+
+class Solution:
+ def maxProfit(self, k: int, prices) -> int:
+ if not k or not prices:
+ return 0
+
+ last = prices[0]
+ status = 0
+ last_min = None
+ heap = []
+ for price in prices:
+ if last == price:
+ continue
+ if price > last:
+ if status != 1:
+ last_min = last
+ status = 1
+ else:
+ if status != -1:
+ if last_min is not None:
+ self.push(heap, k, last - last_min)
+ status = -1
+
+ last = price
+ if status == 1:
+ self.push(heap, k, last - last_min)
+
+ return sum(sorted(heap[-k:]))
+
+ def push(self, heap, k, value):
+ if len(heap) >= k:
+ heapq.heapreplace(heap, value)
+ else:
+ heapq.heappush(heap, value)
+
+
+s = Solution()
+# print(s.maxProfit(2, [2, 1, 2, 0, 1]))
+# print(s.maxProfit(2, [2, 4, 1]))
+# print(s.maxProfit(2, [1, 4, 2, 7]))
+# print(s.maxProfit(2, [3, 2, 6, 5, 0, 3]))
+# print(s.maxProfit(2, [3, 3, 5, 0, 0, 3, 1, 4]))
+# print(s.maxProfit(2, [1, 2, 4, 2, 5, 7, 2, 4, 9, 0]))
diff --git a/Week_04/id_3/dp/LeetCode_188_3_v4.py b/Week_04/id_3/dp/LeetCode_188_3_v4.py
new file mode 100644
index 00000000..315d0801
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_188_3_v4.py
@@ -0,0 +1,8 @@
+"""
+反复练习版本
+"""
+
+
+class Solution:
+ def maxProfit(self, k: int, prices) -> int:
+ pass
diff --git a/Week_04/id_3/dp/LeetCode_198_3_v1.py b/Week_04/id_3/dp/LeetCode_198_3_v1.py
new file mode 100644
index 00000000..df7b2a54
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_198_3_v1.py
@@ -0,0 +1,31 @@
+"""
+第一直观的解法还是dfs,先试试
+===============
+超时了 要加上缓存
+===============
+超过97.8%
+"""
+
+
+class Solution:
+ def rob(self, nums):
+ if not nums:
+ return 0
+ return self.dfs(False, 0, nums, [None]*len(nums))
+
+ def dfs(self, prev_steal, index, nums, cache):
+ if index >= len(nums):
+ return 0
+
+ if not cache[index]:
+ r1 = self.dfs(False, index+1, nums, cache)
+ r2 = nums[index] + self.dfs(True, index+1, nums, cache)
+ cache[index] = (r1, max(r1, r2))
+
+ results = cache[index]
+ return results[0] if prev_steal else results[1]
+
+
+s = Solution()
+print(s.rob([1, 2, 3, 1]), s.rob([1, 2, 3, 1]) == 4)
+print(s.rob([2, 7, 9, 3, 1]), s.rob([2, 7, 9, 3, 1]) == 12)
diff --git a/Week_04/id_3/dp/LeetCode_198_3_v2.py b/Week_04/id_3/dp/LeetCode_198_3_v2.py
new file mode 100644
index 00000000..88f01930
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_198_3_v2.py
@@ -0,0 +1,40 @@
+"""
+使用非递归方式解决
+=======
+套路 递归+缓存 可以解决的问题,容易直接推出递推公式
+
+递归的思路一般是从大到小,n问题依赖n-1问题的解决(也有例外)
+
+递推是从底部开始推导最优解 自底向上 将原来缓存中的值计算出来
+
+=======
+本题的解法就 n下标 的最优解是 nums[n] + cache[n-2] 与 cache[n-1] 之间的比较
+"""
+
+
+class Solution:
+ def rob(self, nums):
+ if not nums:
+ return 0
+
+ length = len(nums)
+ if length == 1:
+ return nums[0]
+
+ cache = [nums[0], max(nums[0], nums[1])]
+ index = 2
+ while index < length:
+ cache.append(
+ max(
+ nums[index] + cache[index - 2],
+ cache[index - 1]
+ )
+ )
+ index += 1
+
+ return cache[index - 1]
+
+
+s = Solution()
+print(s.rob([1, 2, 3, 1]), s.rob([1, 2, 3, 1]) == 4)
+print(s.rob([2, 7, 9, 3, 1]), s.rob([2, 7, 9, 3, 1]) == 12)
diff --git a/Week_04/id_3/dp/LeetCode_213_3_v1.py b/Week_04/id_3/dp/LeetCode_213_3_v1.py
new file mode 100644
index 00000000..b05e7867
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_213_3_v1.py
@@ -0,0 +1,38 @@
+"""
+先按自己的方法试试
+回溯 + 2状态缓存 第一家偷不偷 本家偷不偷
+"""
+
+
+class Solution:
+ def rob(self, nums) -> int:
+ if not nums:
+ return 0
+ if len(nums) == 1:
+ return nums[0]
+ return self.rec(0, 0, 0, nums, [[None, None] for _ in range(len(nums)-1)])
+
+ def rec(self, idx, prev, first, nums, cache):
+ if idx == len(nums) - 1:
+ return nums[idx] if not prev and not first else 0
+
+ next_x = idx + 1
+ if idx == 0:
+ return max(
+ self.rec(next_x, 0, 0, nums, cache),
+ nums[0] + self.rec(next_x, 1, 1, nums, cache)
+ )
+
+ if not cache[idx][first]:
+ r1 = self.rec(next_x, 0, first, nums, cache)
+ r2 = nums[idx] + self.rec(next_x, 1, first, nums, cache)
+ cache[idx][first] = [r1, r2]
+
+ r1, r2 = cache[idx][first]
+ return r1 if prev == 1 else max(r1, r2)
+
+
+s = Solution()
+# print(s.rob([2, 3, 2]) == 3)
+# print(s.rob([1, 2, 3, 2]) == 4)
+print(s.rob([1, 2, 3, 1]) == 4)
diff --git a/Week_04/id_3/dp/LeetCode_213_3_v2.py b/Week_04/id_3/dp/LeetCode_213_3_v2.py
new file mode 100644
index 00000000..60896bc7
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_213_3_v2.py
@@ -0,0 +1,35 @@
+"""
+DP思路 缓存依然是两个状态 首家偷不偷 本家偷不偷
+cache = [首不偷本不偷, 首不偷本偷, 首偷本不偷, 首偷本偷]
+在初始状态和最后结果状态容易下标判断错误
+"""
+
+
+class Solution:
+ def rob(self, nums) -> int:
+ if not nums:
+ return 0
+ if len(nums) == 1:
+ return nums[0]
+ if len(nums) == 2:
+ return max(nums)
+
+ # 初始状态从下标2开始比较容易实现
+ cache = [0, nums[1], nums[0], nums[0]]
+ for i in range(2, len(nums) - 1):
+ v = nums[i]
+ cache = [
+ max(cache[0], cache[1]),
+ v + cache[0],
+ max(cache[2], cache[3]),
+ v + cache[2],
+ ]
+
+ last = nums[len(nums) - 1]
+ return max(last + cache[0], cache[1], cache[2], cache[3])
+
+
+s = Solution()
+print(s.rob([2, 3, 2]) == 3)
+print(s.rob([1, 2, 3, 2]) == 4)
+print(s.rob([1, 2, 3, 1]) == 4)
diff --git a/Week_04/id_3/dp/LeetCode_309_3_v1.py b/Week_04/id_3/dp/LeetCode_309_3_v1.py
new file mode 100644
index 00000000..367e2186
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_309_3_v1.py
@@ -0,0 +1,59 @@
+"""
+给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。
+
+设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票):
+
+你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
+卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。
+示例:
+
+输入: [1,2,3,0,2]
+输出: 3
+解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出]
+
+=======================
+DP还是不熟,需要可以练习,先从暴力解法开始。
+status 0不操作 1买 2卖
+在recursion三个参数 下标 上一次的状态 数据
+三种状态三种不同的下钻方式
+技巧在于买入不卖的等待状态相当于每次的累加 每一步的状态都可以计算 便于缓存
+price[5]-price[2] = (prices[3]-price[2])+(prices[4]-price[3])...
+=======================
+加入缓存 参数其实就是状态 当前下标配合当前状态构成了一个缓存
+注意 二维数组初始化不可以这么写 [[0,0,0]]*n 这样所有数组的子元素都引用的同一个二级数组 [0,0,0]
+
+完美,一条过 打败93%
+"""
+
+
+class Solution:
+ def maxProfit(self, prices) -> int:
+ if not prices:
+ return 0
+ return self.recursion(0, 0, prices, [[None, None, None] for _ in range(len(prices))])
+
+ def recursion(self, idx, status, prices, cache):
+ if idx >= len(prices):
+ return 0
+ if cache[idx][status] is not None:
+ return cache[idx][status]
+ if status == 0:
+ r = max(
+ self.recursion(idx+1, 0, prices, cache),
+ self.recursion(idx+1, 1, prices, cache)
+ )
+ elif status == 1:
+ r = (prices[idx] - prices[idx-1]) + max(
+ self.recursion(idx+1, 1, prices, cache),
+ self.recursion(idx+1, 2, prices, cache),
+ )
+ elif status == 2:
+ r = self.recursion(idx+1, 0, prices, cache)
+ cache[idx][status] = r
+ return r
+
+
+s = Solution()
+print(s.maxProfit([1, 2, 3, 0, 2, 4, 5, 7, 8]) == 9)
+print(s.maxProfit([1, 2, 3, 0, 2]) == 3)
+print(s.maxProfit([1, 2, 3, -2, 5, 0, 2]) == 8)
diff --git a/Week_04/id_3/dp/LeetCode_309_3_v2.py b/Week_04/id_3/dp/LeetCode_309_3_v2.py
new file mode 100644
index 00000000..6bead42f
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_309_3_v2.py
@@ -0,0 +1,63 @@
+"""
+给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。
+
+设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票):
+
+你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
+卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。
+示例:
+
+输入: [1,2,3,0,2]
+输出: 3
+解释: 对应的交易状态为: [买入, 卖出, 冷冻期, 买入, 卖出]
+
+=======================
+尝试dp递推
+按套路是写出来了,但是真的好难按正常思路去理解。
+尝试理解一下
+
+所谓的自底向上还是很难理解,还是顺序写dp比较容易理解
+当前如果是空仓 则最大值是 之前空仓或者卖出的最大值
+如果是买入状态 则最大值是 之前空仓或者买入状态+差值的最大值
+如果是卖出操作 则最大值是 之前是买入状态的最大值
+======================
+优化缓存数组,减少内存使用。目前这种n只依赖n-1的dp,没必要记录全量。
+内存占用打败 98.84%
+======================
+还得多练练
+"""
+
+
+class Solution:
+ def maxProfit(self, prices) -> int:
+ if not prices:
+ return 0
+ return self.dp2(prices)
+
+ def dp1(self, prices):
+ cache = (0, 0, 0)
+ for idx in range(len(prices) - 1, 0, -1):
+ d = prices[idx] - prices[idx - 1]
+ cache = (
+ max(cache[0], cache[1]),
+ max(cache[1], cache[2]) + d,
+ cache[0],
+ )
+ return max(cache[0], cache[1])
+
+ def dp2(self, prices):
+ cache = (0, 0, 0)
+ for idx in range(1, len(prices)):
+ d = prices[idx] - prices[idx - 1]
+ cache = (
+ max(cache[0], cache[2]),
+ max(cache[0], cache[1] + d),
+ cache[1] + d
+ )
+ return max(cache)
+
+
+s = Solution()
+print(s.maxProfit([1, 2, 3, 0, 2, 4, 5, 7, 8]), s.maxProfit([1, 2, 3, 0, 2, 4, 5, 7, 8]) == 9)
+print(s.maxProfit([1, 2, 3, 0, 2]), s.maxProfit([1, 2, 3, 0, 2]) == 3)
+print(s.maxProfit([1, 2, 3, -2, 5, 0, 2]), s.maxProfit([1, 2, 3, -2, 5, 0, 2]) == 8)
diff --git a/Week_04/id_3/dp/LeetCode_322_3_v1.py b/Week_04/id_3/dp/LeetCode_322_3_v1.py
new file mode 100644
index 00000000..8168ba30
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_322_3_v1.py
@@ -0,0 +1,31 @@
+class Solution:
+ def coinChange(self, coins, amount: int) -> int:
+ if not coins:
+ return -1
+
+ return self.dfs(coins, amount, [None] * (amount+1))
+
+ def dfs(self, coins, amount, cache):
+ if amount == 0:
+ return 0
+
+ if amount < 0:
+ return -1
+
+ if cache[amount] is None:
+ result = -1
+ for c in coins:
+ r = self.dfs(coins, amount - c, cache)
+ if r == -1:
+ continue
+ r += 1
+ result = r if result == -1 else min(result, r)
+
+ cache[amount] = result
+
+ return cache[amount]
+
+
+s = Solution()
+print(s.coinChange([1, 2, 5], 11) == 3)
+print(s.coinChange([186, 419, 83, 408], 6249))
diff --git a/Week_04/id_3/dp/LeetCode_337_3_v1.py b/Week_04/id_3/dp/LeetCode_337_3_v1.py
new file mode 100644
index 00000000..879c740c
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_337_3_v1.py
@@ -0,0 +1,58 @@
+"""
+在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区。这个地区只有一个入口,我们称之为“根”。 除了“根”之外,每栋房子有且只有一个“父“房子与之相连。一番侦察之后,聪明的小偷意识到“这个地方的所有房屋的排列类似于一棵二叉树”。 如果两个直接相连的房子在同一天晚上被打劫,房屋将自动报警。
+
+计算在不触动警报的情况下,小偷一晚能够盗取的最高金额。
+
+示例 1:
+
+输入: [3,2,3,null,3,null,1]
+
+ 3
+ / \
+ 2 3
+ \ \
+ 3 1
+
+输出: 7
+解释: 小偷一晚能够盗取的最高金额 = 3 + 3 + 1 = 7.
+示例 2:
+
+输入: [3,4,5,1,3,null,1]
+
+ 3
+ / \
+ 4 5
+ / \ \
+ 1 3 1
+
+输出: 9
+解释: 小偷一晚能够盗取的最高金额 = 4 + 5 = 9.
+
+# Definition for a binary tree node.
+# class TreeNode:
+# def __init__(self, x):
+# self.val = x
+# self.left = None
+# self.right = None
+
+依然先用传统的回溯+缓存
+"""
+
+
+class Solution:
+ def rob(self, root) -> int:
+ if not root:
+ return 0
+ return self.rec(root, False, {})
+
+ def rec(self, node, prev, cache):
+ if not node:
+ return 0
+ _id = id(node)
+ if _id not in cache:
+ r1 = self.rec(node.left, False, cache) + self.rec(node.right, False, cache)
+ r2 = node.val + self.rec(node.left, True, cache) + self.rec(node.right, True, cache)
+ cache[_id] = (r1, r2)
+
+ r1, r2 = cache[_id]
+ return r1 if prev else max(r1, r2)
diff --git a/Week_04/id_3/dp/LeetCode_337_3_v2.py b/Week_04/id_3/dp/LeetCode_337_3_v2.py
new file mode 100644
index 00000000..cf776f25
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_337_3_v2.py
@@ -0,0 +1,27 @@
+"""
+DP的思路目前是广度优先策略用dict缓存父级的递归结果
+不过卡住了,自从向叶的dp似乎最终很难汇集一个结果,得试试自叶向根了。
+====================
+看了各路答案,思路本题很难用递推处理 失败
+"""
+
+
+class Solution:
+ def rob(self, root) -> int:
+ if not root:
+ return 0
+
+ cache = {id(root): (0, 0)}
+ queue = [root]
+
+ result = 0
+ while queue:
+ _queue = []
+ _cache = {}
+ for node in queue:
+ p1, p2 = cache[id(node)]
+ r = (max(p1, p2), p1 + node.val)
+ if not node.left and not node.right:
+ pass
+
+ return result
diff --git a/Week_04/id_3/dp/LeetCode_337_3_v3.py b/Week_04/id_3/dp/LeetCode_337_3_v3.py
new file mode 100644
index 00000000..022b270f
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_337_3_v3.py
@@ -0,0 +1,22 @@
+"""
+有点儿类似用递归模拟递推
+没必要使用回溯+缓存 直接递归下钻即可拿到子节点的类似递推的结果
+算是深度优先+递推 非常简单高效
+击败接近100%
+"""
+
+
+class Solution:
+ def rob(self, root) -> int:
+ if not root:
+ return 0
+ return max(self.dfs(root))
+
+ def dfs(self, node):
+ if not node:
+ return 0, 0
+
+ l1, l2 = self.dfs(node.left)
+ r1, r2 = self.dfs(node.right)
+
+ return max(l1 + r1, l2 + r1, l1 + r2, l2 + r2), node.val + l1 + r1
diff --git a/Week_04/id_3/dp/LeetCode_62_3_v1.py b/Week_04/id_3/dp/LeetCode_62_3_v1.py
new file mode 100644
index 00000000..8ea8ca76
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_62_3_v1.py
@@ -0,0 +1,50 @@
+"""
+一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。
+
+机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
+
+问总共有多少条不同的路径?
+
+例如,上图是一个7 x 3 的网格。有多少可能的路径?
+
+说明:m 和 n 的值均不超过 100。
+
+示例 1:
+
+输入: m = 3, n = 2
+输出: 3
+解释:
+从左上角开始,总共有 3 条路径可以到达右下角。
+1. 向右 -> 向右 -> 向下
+2. 向右 -> 向下 -> 向右
+3. 向下 -> 向右 -> 向右
+示例 2:
+
+输入: m = 7, n = 3
+输出: 28
+===========================
+老套路先试试回溯+缓存
+优化 碰触到右或者下的边可直接返回1
+缓存为m*n数组,mn启点 00终点,这样变量能少传两个。
+"""
+
+
+class Solution:
+ def uniquePaths(self, m: int, n: int) -> int:
+ if not m or not n:
+ return 0
+ return self.rec(m-1, n-1, [[None for _ in range(n)] for _ in range(m)])
+
+ def rec(self, m, n, cache):
+ if not m or not n:
+ return 1
+
+ if cache[m][n] is None:
+ cache[m][n] = self.rec(m-1, n, cache) + self.rec(m, n-1, cache)
+
+ return cache[m][n]
+
+
+s = Solution()
+print(s.uniquePaths(3, 2) == 3)
+print(s.uniquePaths(7, 3) == 28)
diff --git a/Week_04/id_3/dp/LeetCode_62_3_v2.py b/Week_04/id_3/dp/LeetCode_62_3_v2.py
new file mode 100644
index 00000000..8f2e83f5
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_62_3_v2.py
@@ -0,0 +1,26 @@
+"""
+老套路 DP递推 自底向上
+00默认是终点递推比较容易
+"""
+
+
+class Solution:
+ def uniquePaths(self, m: int, n: int) -> int:
+ if not m or not n:
+ return 0
+
+ cache = [1] * n
+ for _m in range(1, m):
+ _cache = [1] * n
+ for _n in range(1, n):
+ _cache[_n] = _cache[_n-1] + cache[_n]
+
+ cache = _cache
+
+ return cache[n - 1]
+
+
+s = Solution()
+print(s.uniquePaths(3, 2) == 3)
+print(s.uniquePaths(7, 3) == 28)
+print(s.uniquePaths(3, 7) == 28)
diff --git a/Week_04/id_3/dp/LeetCode_63_3_v1.py b/Week_04/id_3/dp/LeetCode_63_3_v1.py
new file mode 100644
index 00000000..bf433bf4
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_63_3_v1.py
@@ -0,0 +1,49 @@
+"""
+一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。
+
+机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。
+
+现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径?
+
+===================================
+老套路 先递归
+直接用初始化数组当缓存
+用None取代本来是结果0的点位 避免重复计算 -1取代障碍物点位
+"""
+
+
+class Solution:
+ def uniquePathsWithObstacles(self, obstacleGrid) -> int:
+ if not obstacleGrid or not obstacleGrid[0]:
+ return 0
+
+ for m in range(len(obstacleGrid)):
+ for n in range(len(obstacleGrid[0])):
+ obstacleGrid[m][n] = None if obstacleGrid[m][n] == 0 else -1
+
+ return self.rec(0, 0, len(obstacleGrid)-1, len(obstacleGrid[0])-1, obstacleGrid)
+
+ def rec(self, m, n, m_max, n_max, grid):
+ if m > m_max or n > n_max:
+ return 0
+
+ if grid[m][n] == -1:
+ return 0
+
+ if m == m_max and n == n_max:
+ return 1
+
+ if grid[m][n] is None:
+ grid[m][n] = self.rec(m+1, n, m_max, n_max, grid) + self.rec(m, n+1, m_max, n_max, grid)
+
+ return grid[m][n]
+
+
+s = Solution()
+print(s.uniquePathsWithObstacles([
+ [0, 0, 0],
+ [0, 1, 0],
+ [0, 0, 0]
+]))
+print(s.uniquePathsWithObstacles([[1, 0]]))
+print(s.uniquePathsWithObstacles([[0, 1]]))
diff --git a/Week_04/id_3/dp/LeetCode_63_3_v2.py b/Week_04/id_3/dp/LeetCode_63_3_v2.py
new file mode 100644
index 00000000..e3758a7f
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_63_3_v2.py
@@ -0,0 +1,36 @@
+"""
+尝试DP
+"""
+
+
+class Solution:
+ def uniquePathsWithObstacles(self, grid) -> int:
+ if not grid or not grid[0]:
+ return 0
+
+ for m in range(len(grid)):
+ for n in range(len(grid[0])):
+ if grid[m][n] == 1:
+ grid[m][n] = 0
+ continue
+
+ if m == 0 and n == 0:
+ grid[m][n] = 1
+ continue
+
+ if n > 0:
+ grid[m][n] += grid[m][n-1]
+ if m > 0:
+ grid[m][n] += grid[m-1][n]
+
+ return grid[m][n]
+
+
+s = Solution()
+print(s.uniquePathsWithObstacles([
+ [0, 0, 0],
+ [0, 1, 0],
+ [0, 0, 0]
+]))
+print(s.uniquePathsWithObstacles([[1, 0]]))
+print(s.uniquePathsWithObstacles([[0, 1]]))
diff --git a/Week_04/id_3/dp/LeetCode_70_3_v1.py b/Week_04/id_3/dp/LeetCode_70_3_v1.py
new file mode 100644
index 00000000..efb3ea09
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_70_3_v1.py
@@ -0,0 +1,35 @@
+"""
+先用第一印象的数学公式解决
+======
+想到的不行 本质是个n^n 的解决方案
+======
+试试递归+缓存的玩法
+"""
+import math
+
+
+class Solution:
+ def climbStairs(self, n: int) -> int:
+ if not n:
+ return 0
+ return self.stair(n, [0] * (n+1))
+
+ def stair(self, n, cache):
+ if n == 0:
+ return 0
+ if n == 1:
+ return 1
+ if n == 2:
+ return 2
+
+ if cache[n]:
+ return cache[n]
+
+ r = self.stair(n-1, cache) + self.stair(n-2, cache)
+ cache[n] = r
+ return r
+
+
+s = Solution()
+# print(s.climbStairs(3))
+print(s.climbStairs(4))
diff --git a/Week_04/id_3/dp/LeetCode_70_3_v2.py b/Week_04/id_3/dp/LeetCode_70_3_v2.py
new file mode 100644
index 00000000..8adc4f8f
--- /dev/null
+++ b/Week_04/id_3/dp/LeetCode_70_3_v2.py
@@ -0,0 +1,22 @@
+"""
+递推比较直观 n = cache[n-1]+cache[n-2]
+"""
+
+
+class Solution:
+ def climbStairs(self, n: int) -> int:
+ if not n:
+ return 0
+
+ cache = [1, 1]
+ index = 2
+ while index <= n:
+ cache.append(cache[index - 1] + cache[index - 2])
+ index += 1
+
+ return cache[n]
+
+
+s = Solution()
+print(s.climbStairs(4))
+print(s.climbStairs(10))
diff --git a/Week_04/id_3/greed/LeetCode_455_3_v1.py b/Week_04/id_3/greed/LeetCode_455_3_v1.py
new file mode 100644
index 00000000..6adce50f
--- /dev/null
+++ b/Week_04/id_3/greed/LeetCode_455_3_v1.py
@@ -0,0 +1,30 @@
+"""
+直接贪心好了,最大的饼干找胃口最大的孩子
+"""
+
+
+class Solution:
+ def findContentChildren(self, g, s) -> int:
+ if not g or not s:
+ return 0
+
+ s.sort()
+ g.sort()
+
+ gi = len(g)
+ r = 0
+ for si in range(len(s) - 1, - 1, -1):
+ sv = s[si]
+ for gi in range(gi - 1, -1, -1):
+ gv = g[gi]
+ if gv <= sv:
+ r += 1
+ break
+
+ return r
+
+
+s = Solution()
+print(s.findContentChildren([1, 2, 3], [1, 1]))
+print(s.findContentChildren([1, 2], [1, 2, 3]))
+print(s.findContentChildren([10, 9, 8, 7], [5, 6, 7, 8]))
diff --git a/Week_04/id_3/trie/LeetCode_208_3.py b/Week_04/id_3/trie/LeetCode_208_3.py
new file mode 100644
index 00000000..3cb44147
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_208_3.py
@@ -0,0 +1,57 @@
+class Trie:
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def insert(self, word: str) -> None:
+ node = self.root
+ for c in word:
+ if c not in node.edges:
+ node.edges[c] = TrieNode()
+ node.letter = c
+ node = node.edges[c]
+ node.is_word = True
+
+ def search(self, word: str) -> bool:
+ if not word:
+ return False
+ node = self.root
+ for c in word:
+ if c in node.edges:
+ node = node.edges[c]
+ else:
+ return False
+
+ return node.is_word
+
+ def startsWith(self, prefix: str) -> bool:
+ if not prefix:
+ return False
+ node = self.root
+ for c in prefix:
+ if c in node.edges:
+ node = node.edges[c]
+ else:
+ return False
+
+ return True
+
+
+class TrieNode:
+
+ def __init__(self):
+ self.edges = {}
+ self.letter = None
+ self.is_word = False
+
+
+trie = Trie()
+
+trie.insert("apple")
+print(trie.search("apple"))
+print(trie.search("app"))
+print(trie.startsWith("app"))
+trie.insert("app")
+print(trie.search("app"))
+
+
diff --git a/Week_04/id_3/trie/LeetCode_211_3.py b/Week_04/id_3/trie/LeetCode_211_3.py
new file mode 100644
index 00000000..3bd9e154
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_211_3.py
@@ -0,0 +1,53 @@
+class WordDictionary:
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def addWord(self, word: str) -> None:
+ node = self.root
+ for c in word:
+ if c not in node.edges:
+ node.edges[c] = TrieNode()
+ node.letter = c
+ node = node.edges[c]
+ node.is_word = True
+
+ def search(self, word: str) -> bool:
+ if not word:
+ return False
+ return self._dfs(self.root, word)
+
+ def _dfs(self, node, word):
+ for i in range(len(word)):
+ c = word[i]
+
+ if c == '.':
+ for sn in node.edges.values():
+ if self._dfs(sn, word[i+1:]):
+ return True
+ return False
+
+ if c in node.edges:
+ node = node.edges[c]
+ else:
+ return False
+
+ return node.is_word
+
+
+class TrieNode:
+
+ def __init__(self):
+ self.edges = {}
+ self.letter = None
+ self.is_word = False
+
+
+trie = WordDictionary()
+trie.addWord("bad")
+trie.addWord("dad")
+trie.addWord("mad")
+print(trie.search('pad'))
+print(trie.search('bad'))
+print(trie.search('.ad'))
+print(trie.search('b..'))
diff --git a/Week_04/id_3/trie/LeetCode_720_3_v1.py b/Week_04/id_3/trie/LeetCode_720_3_v1.py
new file mode 100644
index 00000000..583a780f
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_720_3_v1.py
@@ -0,0 +1,56 @@
+import collections
+
+
+class TrieTree:
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def add(self, word):
+ node = self.root
+ for w in word:
+ node = node.edges[w]
+ node.letter = w
+ node.is_word = True
+
+
+class TrieNode:
+
+ def __init__(self):
+ self.edges = collections.defaultdict(TrieNode)
+ self.letter = None
+ self.is_word = False
+
+
+class Solution:
+ def longestWord(self, words):
+ if not words:
+ return ''
+
+ tree = TrieTree()
+ for word in words:
+ if word == '':
+ continue
+ tree.add(word)
+
+ self.result = []
+ self.dfs(tree.root, [])
+ return ''.join(self.result)
+
+ def dfs(self, node, curr):
+ curr.append(node.letter)
+ if (len(curr) - 1) > len(self.result):
+ self.result[:] = curr[1:]
+
+ for key in sorted(node.edges.keys()):
+ sn = node.edges[key]
+ if sn.is_word:
+ self.dfs(sn, curr)
+
+ curr.pop()
+
+
+s = Solution()
+# print(s.longestWord(["w", "wo", "wor", "worl", "world"]))
+# print(s.longestWord(["a", "banana", "app", "appl", "ap", "apply", "apple"]))
+print(s.longestWord( ["e", "el", "ele", "elep", "eleph", "elepha", "elephan", "elephant"]))
diff --git a/Week_04/id_3/trie/LeetCode_720_3_v2.py b/Week_04/id_3/trie/LeetCode_720_3_v2.py
new file mode 100644
index 00000000..315321c0
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_720_3_v2.py
@@ -0,0 +1,61 @@
+"""
+尝试用数组实现Trie树 但是性能似乎没啥改善
+"""
+letter_a = ord('a')
+
+
+class TrieTree:
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def add(self, word):
+ node = self.root
+ for w in word:
+ index = ord(w) % letter_a
+ if not node.edges[index]:
+ node.edges[index] = TrieNode()
+ node = node.edges[index]
+ node.letter = w
+ node.is_word = True
+
+
+class TrieNode:
+
+ def __init__(self):
+ self.edges = [None] * 26
+ self.letter = None
+ self.is_word = False
+
+
+class Solution:
+ def longestWord(self, words):
+ if not words:
+ return ''
+
+ tree = TrieTree()
+ for word in words:
+ if word == '':
+ continue
+ tree.add(word)
+
+ self.result = []
+ self.dfs(tree.root, [])
+ return ''.join(self.result)
+
+ def dfs(self, node, curr):
+ curr.append(node.letter)
+ if (len(curr) - 1) > len(self.result):
+ self.result[:] = curr[1:]
+
+ for sn in node.edges:
+ if not sn or not sn.is_word:
+ continue
+ self.dfs(sn, curr)
+ curr.pop()
+
+
+s = Solution()
+print(s.longestWord(["w", "wo", "wor", "worl", "world"]))
+print(s.longestWord(["a", "banana", "app", "appl", "ap", "apply", "apple"]))
+print(s.longestWord( ["e", "el", "ele", "elep", "eleph", "elepha", "elephan", "elephant"]))
diff --git a/Week_04/id_3/trie/LeetCode_720_3_v3.py b/Week_04/id_3/trie/LeetCode_720_3_v3.py
new file mode 100644
index 00000000..0b203f27
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_720_3_v3.py
@@ -0,0 +1,65 @@
+"""
+在v1基础上尝试做更多的剪枝操作
+====
+加入count 尝试提前过滤掉不需要访问的节点
+时间复杂度O(n*k) k是单词平均长度
+"""
+import collections
+
+
+class TrieTree:
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def add(self, word):
+ node = self.root
+ for w in word:
+ node = node.edges[w]
+ node.letter = w
+ node.count += 1
+ node.is_word = True
+
+
+class TrieNode:
+
+ def __init__(self):
+ self.edges = collections.defaultdict(TrieNode)
+ self.count = 0
+ self.letter = None
+ self.is_word = False
+
+
+class Solution:
+ def longestWord(self, words):
+ if not words:
+ return ''
+
+ tree = TrieTree()
+ for word in words:
+ if word == '':
+ continue
+ tree.add(word)
+
+ self.result = []
+ self.dfs(tree.root, [])
+ return ''.join(self.result)
+
+ def dfs(self, node, curr):
+ curr.append(node.letter)
+ diff_length = len(curr) - 1 - len(self.result)
+ if diff_length > 0:
+ self.result[:] = curr[1:]
+
+ for key in sorted(node.edges.keys()):
+ sn = node.edges[key]
+ if sn.is_word and sn.count >= diff_length:
+ self.dfs(sn, curr)
+
+ curr.pop()
+
+
+s = Solution()
+print(s.longestWord(["w", "wo", "wor", "worl", "world"]))
+print(s.longestWord(["a", "banana", "app", "appl", "ap", "apply", "apple"]))
+print(s.longestWord( ["e", "el", "ele", "elep", "eleph", "elepha", "elephan", "elephant"]))
diff --git a/Week_04/id_3/trie/LeetCode_720_3_v4.py b/Week_04/id_3/trie/LeetCode_720_3_v4.py
new file mode 100644
index 00000000..c8dd4111
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_720_3_v4.py
@@ -0,0 +1,384 @@
+"""
+我对题目之前有个误解,一定要从1个字母开始才行
+Trie树性能似乎比不过人家,试试O(nlogn)
+倒序遍历words有3个目的
+1 最终需要有单词是一个字母的才算数,倒序更容易写
+2 更容易剪枝,长度不够的直接pass
+3 由于相同的答案要按字典排序 所以在前的要覆盖在后的答案
+
+=====我错了 这么整不行
+不用trie 这么多用例过不了 好麻烦
+真的是太折磨人了 各种出乎意料的用例
+=======================
+真特么不容易 总算通过了 确实效率提高了
+=======================
+v5有个更高效的实现
+"""
+
+
+class Solution:
+ def longestWord(self, words):
+ if not words:
+ return ''
+ words.sort()
+ result = ''
+ rm = {}
+ last = None
+ for i in range(len(words)-1, -1, -1):
+ word = words[i]
+
+ # 被迫去重
+ if word == last:
+ continue
+ else:
+ last = word
+
+ if word not in rm:
+ if len(word) < len(result):
+ continue
+ rm[word] = word
+
+ r = rm.pop(word)
+ if len(r) < len(result):
+ continue
+
+ if len(word) == 1:
+ result = r
+ else:
+ prev = word[:-1]
+ # 有一种情况是后来较短的新加入元素反倒覆盖了早先加入的长元素
+ if prev in rm and len(rm[prev]) > len(r):
+ continue
+ rm[prev] = r
+
+ return result
+
+
+s = Solution()
+# print(s.longestWord(["vsw", "vs", "zwu", "vsx", "nc", "o", "vswus", "orv", "imf", "i", "v", "zw", "vs"]))
+# print(s.longestWord(["w", "wo", "wor", "worl", "world"]))
+# print(s.longestWord(["a", "banana", "app", "appl", "ap", "apply", "apple"]))
+# print(s.longestWord(["e", "el", "ele", "elep", "eleph", "elepha", "elephan", "elephant"]))
+# print(s.longestWord(["ogz", "eyj", "e", "ey", "hmn", "v", "hm", "ogznkb", "ogzn", "hmnm", "eyjuo", "vuq", "ogznk", "og", "eyjuoi", "d"]))
+# print(s.longestWord(["m", "mo", "moc", "moch", "mocha", "l", "la", "lat", "latt", "latte", "c", "ca", "cat"]))
+# print(s.longestWord(["rac", "rs", "ra", "on", "r", "otif", "o", "onpdu", "rsf", "rs", "ot", "oti", "racy", "onpd"]))
+# print(s.longestWord(
+# ["ts", "e", "x", "pbhj", "opto", "xhigy", "erikz", "pbh", "opt", "erikzb", "eri", "erik", "xlye", "xhig", "optoj",
+# "optoje", "xly", "pb", "xhi", "x", "o"]))
+print(s.longestWord(
+ ["unnmgrejgrdhyhtlnotakcfrumgchf", "unnmgrejgrdhyhtlnotakcfrumgcko", "unnmgrejgrdhyhtlnotakcfrumgcnt",
+ "unnmgtdwmfdrggjhwiveakaans", "unnmgrejgkxvrsrcutgmozxwfxtyh", "unnmgrejgrdhyhtlnotakcfrumgckb",
+ "unnmgrejgrtseekgfsqrpzarrugyoo", "unnmgrejgrdhyhtlnotafgintna", "unnmgrejgrdhyhtlnotakcfrumgcc",
+ "unnmgrejgrdhyhtlnotakcfrumgcae", "unnmgrejgrdhyhtlnotakcf", "unnmgrejgrdhyhtlnotakcfrumgczf",
+ "unnmgrejgrdhyhtlnotakcfrumgcuu", "unnmgrejgrdhyhtlnotakcfrumgcgb", "unnmgrejgrdhyhtlnotakstpse",
+ "unnmgrejgrdhyhtlnotalrrfbhxfwr", "unnmgrejgrdhyhtlnotakcfrumgcle", "unnmgrejgrdhyhtlnotakcfrumgcia",
+ "unnmgrejgrdhyhtlno", "unnmgrejjnoewygegmereqavjufj", "unnmgrejgrdhyhtlnotakcfrumgcnj",
+ "unnmgrejgrdhyhtlnotakcfrumgcli", "unnmgrejgrdhyhtlnotakcfrumgcqg", "unnmgrejgrdhyhtlnotakcfrumgcdc",
+ "unnmgrejgrdhyhtlnotakcfrumgcqz", "unnmgrejgrdhyhtlnotakcfrumgcnx", "unnolyiqthfxeeuiqwyyyxa",
+ "unnmgrejgrdhyhtlnoteeqstntxyzb", "unnmgrejgrdhyhtlnotakcfrumgcom", "unnmgr", "unnmgrejgrdhyhtlnotakcfrumgcmb",
+ "unnmgrejgrdhyhtlnotakcfrumgcka", "unnmgrejgrdhyhtlnotakcfrumgcqs", "fwqhslqjtdkkuqfmydynsaaiiepp",
+ "unnmgrejgrdibavjwpkovmmdga", "unnmgrejgrdhyhtlnotakcfrumgczz", "unnmgrejgrdhyhtlpraihr", "unnmgrenxlnedexgyvpeyb",
+ "unnmgrejgrdhyhtlnotakcfrumgctm", "unnmgrejgrdhyhtlnotakcfrumgcvs", "unnmgrejgrdhyhtlnotakcfrumgcou",
+ "unnmbatzovqozurvkwzpumnfpjp", "unnmgrejgrdhyhtlnotakcfrumgcbj", "unnmgrejgrdhyhtlnotakcfrumgcpz",
+ "unnmgrejgrdhyhtlnotakcfrumgcqu", "unnmgrejgrdhyhtlnotakcfrumgcux", "unnmgrejgrdhyhtlnotakcfrumgchq",
+ "unnmgrejgrdhyhtlnotakcfrumgcxo", "unnmgrejgrdhyhtlnotakcfrumgcrp", "unnmgrejgrdhyhtlnotakcfrumgcpf",
+ "unnmgrejgrdhyhtlnotakcfrumgcdb", "unnmgrejgrdhyhtlnotakcfrumgcob", "unnmgrejgrdhyhtlnotakcfrumgchn",
+ "unnmgrejgrdhyhtlnotakcfrumgcmq", "unnmgrejgrdhyhtlnotakcfrumgcki", "unnmgrejgrdhyhtlnotakcfrumgcmr",
+ "unnmgrejdlxyrouwopnyciahsbdm", "unnmgrejgrdhyhtlnotakcfrumgclo", "unnmgrejgrdhyhtlnotakcfrumgccn",
+ "unnmgrejgrdhyhtlnov", "unnmgrejgrdhyhtlnotakcfrumgcnq", "unnmgrejgrdhyhtlnotakcfrumgcjj",
+ "unnmgrejgrdhyhtlnotakcfrumgcaa", "unnmgrejgrdhyhtlnotakcfrumgctz", "unnmgrejgrdhyhtlnotakcfrumgchy",
+ "unnmgrejgrdhyhtlnotakcfrumgcpz", "unnmgrejgrdhyhwdmxzjvdqs", "unnmgrejgrdhyhtljwrbasro",
+ "unnmgrejgrdhyhtlnotakcfrumgcfu", "unnmgrejgrdhyhtlnotakcfrumgcbh", "unnmgrejgrdhyhtlnotakcfrumgcax",
+ "unnmgrejgrdhyhtlnotakcfrumgcvg", "unnmgrejgrdhyhtlnotakcfruspsis", "ubhrixkqideeukermfzavtceeezkni",
+ "unnmgrejgrdhyhtlnotakcfrumgcmu", "unnmgrejgrdhzcpmspthzldkfp", "unnmgrejgrdhyhtlnotakcfrumgcfd",
+ "unnmauivdwnusmupaol", "unnmgrejgrdhyhtlnotakcfrumgckt", "unnmgrejgrdhyhtlnotakcfrumfgg",
+ "unnmgrejgrdhyhtlnotakcfrumgcqf", "unnmgrejgrdhyhtlnotakcfrumgczv", "unnmgrejgrdhyhtlnotakcfrumgcme",
+ "unnmgrejgrdhyhtlnotakcfrumgcxr", "unnmgrejgrdhyhtlnotakcfrumgcvo", "unnmgreqkoxaakegbzmjeginff",
+ "unnmgrejgrdhyhtlnotakcfrumgcy", "unnmgrejgrdhyhtlnotakcfrumgcyq", "unnmgrejgrdhyhtlnoqndipxyfl",
+ "unnmgrejgrdhyhtlnotakcfrumgcu", "unnmgrejgrmucinqkufc", "unnmgrejgrdhyhtlnotakcfrumgcrn",
+ "unnmgrejgrdhyhtlnotakcfrumgcoc", "unnmgrejgrdhyhtlnotakcfrumgcqk", "unnmgrejgrdhyhtlnotakcfsek",
+ "unnmgrejgrdhyhtlnotakcfrumgcyn", "unnmgrejgrdhyhtlnotakcg", "unnmgrejgrdhyhtlnotakcfrumgcdm",
+ "unnmgrejgrdhyhtlnotakcfrumgcuy", "unnmgrejgrdhyhtlnotakcfrumgcmi", "unnmgrejgrdhyhtlnotakcfrumgczk",
+ "unnmgrejgrdhyhtlnotakcfrumgcyb", "unnmgrejgrdhyhtlnotzfb", "unnmgrejgrdhyhtlnotakcfrumgcoo",
+ "unnmgrejgrdhyhtlnotakcfrumgcwd", "unnmgrejgrdhyhtlnopszcllz", "unnmgrejgrdhyhtlnotakc",
+ "unnmgrejgrdhyhtlnotakcfrumgcug", "unnmgrejgrdhyhtlnotakcfrumgcgf", "unnmgrejgrdhyhtlnotakcfrumgcok",
+ "unnmgrejgrdhyhtlnotakcfrumgc", "unnmgrejgrdhyhtlnotakcfrumgcto", "unnmgrejgrdhyhtlnotakcfrumgcwk",
+ "uxoiokvrivmlliz", "bdzurkrnwmzw", "unnmgrejgrdhyhtlnotakcfrumgciq", "unnmgrejgrdhyhtlnotakcfrumgcrf",
+ "unnmgrejgrdhyhtlnotakcfrumgcjk", "unnmgrejgrdhyhtlnotakcfrumgcqh", "unnmgrejgrdhyhwerwizdkmk",
+ "unnmgrejgrdhyhjlrqenvntu", "unnmgrejgrdhyhtlnotakcfrumgcwb", "unnmgrejgrdhyhtlnotakcfrumgcge",
+ "unnmgrejgrdhyhtlnotakcfrrcgyjk", "unnmgrejgrdhyhtlnotakcfrumgcum", "unnmgrejgrdhyhtlnotakcfrumgcvj",
+ "unnmgrefmfrwmseeixnapcos", "unnmgrejgrdhyhtlnotakcfrumgcci", "unnmgrejgrdhyhtlnotakcfrumgcgd",
+ "unnmgrejgrdhyhtlnotakcfrumgchv", "unnmgrejgrdhyhtlnotakcfrumgcjc", "unnmgrejgrdhyhtlnotakcfrumgcog",
+ "unnmgrejgrdhyhtlnotakcfrumgce", "unnmgrejgrdhyhtlnotakcfrugdyko", "unnmgrejgrdhyhtlnotakcfrumgcsg",
+ "unnmgrejgrdhyhtlnotakcfrumgcbx", "unnmgrejgrdhyhtlnotakcfrumgcup", "unnmgrejgrdhyhtlnotakcfrumgcth",
+ "unnmgrejgrdhyhtlnotakcfrumgcab", "unnmgqymi", "unnmgrejgrdhgpzjbcbuagqw", "unnmgrejgrdhyhtlnotakcfrumgcdq",
+ "unnmgrejgrdhyhtlnotakcfrumgcxp", "unnmgrejgrdhyhtlnotakcfrumgcve", "unnmgrejgrdhyhyzmdasjavr",
+ "unnmgrejgrdhyhtlnotakcfrumgczg", "unnmgrejgrdhyhtlnotakcfrumgchr", "unnmgrejgrdhyhtlnotakcfrumgcse",
+ "unnmgrejgrdhyhtlnotakcfrumgcdl", "unnmgrejgrdhyhtlnotakcfrumgccq", "unnmgrejgrdhyhtlnotakcfrumgcdu",
+ "unnmgrejgrdhyhtlnotakcfrumgczh", "unnmgrejgrdhyhtlnotakcfrumgcds", "unnmgrejgrdhyhtlnotakcfrumgczj",
+ "unnmgrejgrdhyhtlnotakcfrum", "yulkzvmdhmlymcabaiwabej", "unnmgrejgrdhyhtlnotakcfrumgcig",
+ "unnmgrejgrdhyhtlnotakcfrumgcvq", "unnmgrejgrdhyhtlnotakcfruml", "unnmgrejgrdhyhtlnotakcfrumgcgg", "unnmg",
+ "unnmgrejgrdhyhtlnotakcfrumgcmg", "unnyhsyirirrhqygaacirgwujxfvod", "unnmgrejgrdhyhtlnotakcfrumgclu",
+ "unnmgrejgrdhyhtlnotakcfrumgcsz", "unnmgrejgrdhyhtlnotakcfrumgcof", "unnmgrejgrdhyhtlnotakcfrumgccb",
+ "unnmgrejgrdhyhtlnotakcfrumgckn", "unnmgrejgrdhyhtlnotakcfrumgcsl", "unnmgrejgrdhyhtlnoklagrmfj",
+ "unnmgrejgrdhyhtlnnniso", "unnmgrejgrdhyhtlnotakcfrumgcvz", "unnmgrejgr", "unnmgrejgrdhyhtlnotakcfrumgcxu",
+ "unnmgrejgrdhyhtlnotakcfrumgcin", "unnmgrejgrdhcfvzbreouq", "unnmgrejgrdhyhtlnotakcfrumgcld",
+ "unnmgrejgrdhyhtlnotakcfrumgcue", "unnmgrejgrdhyhtlfgauwx", "unnmgrejgrdhyhtlnotakcfrumgcqw",
+ "unnmgrejgrdhyhtlnotakcfrumgcpu", "unnmgrejgrdhyhtlnotakcfrumgcvi", "unnmgrejgrdhyhtlnotakcfrumgcoq",
+ "unnmgrejgrdhyhtlnotakcfrumgcpo", "unnmgrejgrdhyhtlnotakcfrumgczs", "unnmgrejgaiickcjjbkhhjrysys",
+ "unnmgrejgrdhyhtlnotakcfrumgcd", "u", "unnmgrejgrdhyhtlnotakcfrumgcjp", "unnmgrejgrdhyhtlnotakcfrumgcgk",
+ "unnmgrejgrdhyhtlnotakcfrumgcjz", "unnmgrejgrdhyhtlnotakcfrucsvbp", "unnmgrejgrdhyhtlnotakcfrumgcny",
+ "unnmgrejgrdhyhtlnotnabdnnabj", "unnmgrejgrdhyhtlnotakcfrumgcqo", "unnmgrejgrdhyhtlnotakcfrumgchs",
+ "unnmgrejgrdhyhtlnotakcfrumgcfn", "unnmgrejgrdhyhtlnotakcfrumgcst", "unnmgrejgrdhyhtlnotakcfrumgcdd",
+ "unnmgrejgrdhyhtlnotakcfrumgcsv", "unnmgrejgrpcjtlsjnxwrpm", "unnmgrejgrdhyhtlnotakcfrumgcel",
+ "unnmgrejgrdhyhtlnotakcfrumgcus", "unnmgrejgrdhyhtlnotakcfrumgcu", "unnmgrejgrdhyhtlnjatnmhpnzjom",
+ "unnmgrejgrdhyhtlnotakcfrumgcea", "unnmgrejgrdhyhntfazynbyxzvs", "unnmgrejgrdhyhtlnotakcfruok",
+ "unnmgrejgrdhyhtlnotakcfrumgcym", "unnmgrejgrdhyhtlnotakcfrumgcgx", "unnmgrejgrdhyhtlnotakcfrumgcop",
+ "unnmgrejgrdhyhtlnotakcfrumgcos", "unnmgrejgrdhyhtlnotakcfrumgcxj", "unnmgrejgrdhybisadlnowsttsnzag",
+ "unnmgrejgrdhyhtlnotakcfrumgcpk", "unnmgrejocgg", "unnmgrejgrdhyh", "unnmgrejgrdhyhtlnotakcfrumgcdp",
+ "unnmgrvxapikutsajevxythefrqu", "unnmgrejgrdhyhtlnotakcfrumgcte", "unnmgrejgrdhyhtlnotakcfrumgcaj",
+ "unnmgrejgrdhyhtlnotakcfrumgcfa", "unnmgrejgrdhyhtlnotakcfrumgckx", "unnmgrejgrdhyhtlnotakcfrumgczo",
+ "unnmgrejgrdhyhtlnotakcfrumgcam", "unnmgrejgrdhyhtlnotakcfrumgcee", "unnmgrejgrdhyhtlnotakcfrumgcyw",
+ "unnmgrejgrdhyhtlnotakcfrumgckw", "unnmgrejgrdhyhtlnotakcfrumgcjd", "unnmgrejgrdhyhtlnotakcfrumgcay",
+ "unnmgrejgrdhyhtlnotakcfrumgckg", "unnmgrejgrdhyhtlnotakcfrumgcad", "unnmgrejgrdhyhtlnotakwllss",
+ "unnmeqjoniaczaegfdzou", "unnmgrejgrdhyhtlnotakcfrumgcba", "unnmgrejgrdhyhtlnotakcfrumgcrq",
+ "unnmgrejgrdhyhtlnotakcfrumgo", "unnmgrejgrdhyhtlnotakcfrumgcqe", "unnmgrejgrd", "unnmgrejgrdhyhtlnotakcfrumgcvx",
+ "unnmgrejgrdhyhtlnotakcfrumgcqr", "unnmgrejgrdhyhtlnotakcfrumgcxy", "unnmgrejgrdhyhtlnotakcfrumgcks",
+ "unnmgrejgrdhyhtlnotakcfrumgcuq", "unnmgrejgrdhyhtlnotakcfbad", "unnmgrejgrdhyhtlnotakcfrumgcpa",
+ "unnmgrejgrdhyhtlnotakcfrumgczr", "unnmgrejgrdhyhtlncxovnenmoe", "unnmgrejgrdhyhtlnotakcfrumgcsw",
+ "unnmgrejgrdhyhtlnotakcfrumgctu", "unnmgrejgrdhyhtlnotakcfrumgckk", "unnmgrejgrdhyhtlnotakcfrumgczn",
+ "unnmgrejgraiyrcljbabpsnbxdwdf", "unnmgrejgrdhyhtlsm", "unnmgrejgrdhyhtlnoydbxtdkuf", "ugtozcniwqyt",
+ "unnmgrejgrdhyhtlnotakcfrumgcrs", "unnmgrejgrdhyhtlnotakcfrumgcnf", "unnmgrejgrdhyhtlnotakcfrumfxss",
+ "unnmgrejgrdhyhtlnotakcfrumgco", "unhsffydvo", "unnmgrr", "unnmgrejgrdhyhtlnotakcfrumgcrl",
+ "unnmgfbforatzmkoextfzweoru", "unnmgrejgrdhyhtlnotakcfrumgcyg", "unnmgrejgrdhyhtlnotakcfrumgcaq",
+ "unnmgrejgrdhyhtlnotakcfrumgcwo", "unnmgrejgrdhyhtlnotakcfrumgctl", "unnmgrejgrdhyhtlnotakcfrumgcsm",
+ "unnmgrejgrdhyhtlnotakcfrumgclw", "unnmgrejgrdhyhtlnotakcfrumgcif", "unnmgrejgrdhyhtlnotakcfrumgcqy",
+ "unnmgrejgrdhyhtlnotakcfrumgcnd", "unnmgrejgrdhyhtlnotakcfrumgcov", "unnmgrejgrdhyppoppnjlrnfyhbf",
+ "unnmgrejgrdhyhtlnotakcfrumgcjr", "unnmgrejgrdhyhtlnotakcfrumgcct", "unnmgrejgrdhyhtlnotaaixakv",
+ "unnmgrejgrdhyhtlnotakcfrumgczc", "unnmgrejgrdhyhtlnotakcfrumgckh", "unnmgrejgrdhyhtlnotakcfrumgcgq",
+ "unnmgrejgrdhyhtlnotakcfrumgctw", "unnmgrejgrdhyhtlnotakcfrumgcyv", "unnmgrejgrdhyhtlnotakcfrumgcja",
+ "unnmgrejgrdhyhtlnotakcfrumgcuo", "unnmgrejgrdhyhtlnotakcfrumgcvu", "unnmgrejgrdhyhtlnotakcfrumgcuk",
+ "unnmgrejgrdhyhtlnotakcfrumgcje", "unnmgrejgrdhyhtlnotakcfrumgcls", "unnmgrejgrdhyhtlnotakcfrumgcn",
+ "unnmgrejgrdhyhtlnotakcfrumgceo", "unnmgrejgrdhyhtlnotakcfrumgcmc", "unnmgrejgrdhyhtlnotakcfrumgcsj",
+ "unnmgrejgrdhyhtlnotakcfrumgcfm", "unnmgrejgrdhyhtlnotakcfrumgckr", "unnmgrejgrdhyhtlnotavt",
+ "unnmgrejgrdhyhtlnotakcfrumgcrb", "unnmgrejgrdhyhtlnotakcfrumgcyt", "unnmgrejgrdhyhtlnotakcfrumgced", "unnmgrejgr",
+ "unnmgrejgrdhyhtlnotakcfrumgazp", "unnmgrejgrdhyhtlnotakcfrumgcgh", "unnmgrejgrdhyhtlnotakcfrumgcvn",
+ "unnmgrejgrdhyhtlnotakcfrumgclz", "unnmgrejgrdhv", "unnmgrejgrdhyhtlnotakcap", "unnmgrejgrdhyhtlnotakcfrumgcdn",
+ "unnmgrejgrdhyhtlnotakcfrumgcuf", "unnmgrejgrdhyhtlnotakcfrumgcqn", "unnmgrejgrdhyhtlnotakcfrumgcvt",
+ "unnmgrejgrdhyhtupdlrapwjdgcgdu", "unnmgrejgrdhyhtlnotakcfrumgcwr", "unnmgrejgrdhyhtlnotakcfrumgcx",
+ "unnmgrejgrdhyhtlnotakcfrumgcne", "unnmgrejgrdhyhtlnotakcfrumgccp", "unnmgrejgrdhyhtlnotakcfrumgchk",
+ "unnmgrejgrdhyhtlnotakcfrumgcgj", "unnmgrejgrdhyhtlnotakcfrumgccu", "unnmgrejgrdhyhtnwk",
+ "unnmgrejgrdhyhtlnotakcfrumgcyy", "unnmgrejgrdm", "unnmgrejgrdhyhtlnotakcfruwrgq",
+ "unnmgrejgrdhyhtlnotakcfrumgccm", "unnmgrejgrdhyhtlnotakcfrumgcql", "unnmgrejgrdhyhtlpjxrbyuyy",
+ "unnmgrejgrdhyhtlnotakcfrumgczi", "unnmgrejgrdhyhtlnotakcfrumgciy", "unnmgrejgrdhyhtlnotakcfrumgctd",
+ "unnmgrejgrdhyhtlnotakcfrumg", "unnmgrejgrdhyhtlnotakcfrumgcev", "unnmgzwr", "unnmgrejgrdhyhtlnotakcfrumgcps",
+ "unnmgrejgrdhyhtlnotakcfrumgckj", "unnmgrejgrdhyhtlnotakcfrijs", "unnmgrejgrdhyhtlnotakcfrumgcon",
+ "unnmgrejgrdhyhtlnotarwnjdzsp", "unnmgrejgrdhyhtlnotakcfrumgcla", "unnmgrejgrdhj", "unnmgrejgrdhyhtlnvqttyjkul",
+ "unnmgrejgrdhyhtlnotakcfrumgclx", "unnmgrejgrdhyhtlnotakcfrumgcdx", "unnmgrejgrdhyhtlnotakcfrumgcyz",
+ "unnmgrejgrdhyhtlnotakcfrumgcag", "unnmgrejgrdhyhtlnotakcfrumgcpb", "unnmgrejgrdhyhtlnotakcfrumgcfw",
+ "unnmgrejgrdhyhtlnotakcfrumgceu", "unnfwczbdsxebmzqcngxn", "unnmgrejgrdhyhtlnotakcfrumgcju",
+ "unnmgrejgrdhyhtlnotakcfrumgcgo", "unqnhd", "unnmgrejgrdhyhtlnotakcfrumgciu", "unnmgrejgrdhyhtlnobqjxh",
+ "unnmgrejgrdhyhtlnotakcfrumgcem", "unnmgrejgrdhyhtlnotakcfrumgcud", "unnmgrejgrdhyhtlnotakcfrumgchh",
+ "unnmgrejgrdhyhtlnotakcfrumgcio", "unnmgrejgxofdqcwtidusfpbvjadrd", "unnmgrejgrdhyhtlnotwzqqnpbyy",
+ "unnmgrejgrdhyhtlnotakcfrumgcpt", "unnmgrejgrdhyhtlnopbwqjqtwjo", "unnmgrejgrdhyhtlnotakcfrumgcmo",
+ "unnmgrejgrdhyhtlnotakcfrumgcxd", "unnmgwiy", "unnmgrejgrdhyhtlnotakcfrumgcyl", "unnmgrejgrdhyhtlnotakcfrumgcoj",
+ "unnmgrejgrdhyhtlnotakcfrumgcxm", "unnmgrejgrdhy", "unnmgrejgrdhyhtlnotakcfrumgchw",
+ "unnmgrejgrdhyhtlnotakcfrumgcun", "unnmgrejgrdhyhtlnotakcfrumgczd", "unnmgrejgrdhyhtlnotakcfrumgcdp",
+ "unnmgrejgrdhyhtlnotakcfrumgcbs", "unnmgrejgrdhyhtlnotakcfrumgcce", "unnmgrejgrdhyhtlnotakcfrumgcku",
+ "unnmgrayfnjflpxzcgsneuezjwznr", "unnmgrejbwfvnjievqrnvh", "unnmgrejgrdhyhtlnotakcfrumgctv",
+ "unnmgrejgrdhyhtlnotakcfrumgcpg", "unnmgrejgrdhyhtlnoclylfchqd", "unnmgrejgrdhyhtlnotakcfrumgcfv", "uvmbstlaqcqk",
+ "unnmgrejgrdhyhtlnotakcfrumgceq", "unnmgrejgrdhyhgmimkbgohnx", "unnmgrejgrdhyhtlnotakcm", "unnmgrejgrdhpaojwpitfy",
+ "unnmgrejgrdhyhtlnotakcfrumgcwz", "unnmgrejgrdhyhtbhxfyacquzye", "unnmgrejgrdhyhtlnotakcfrumgcav",
+ "unnmgrejgrdhyhtlnotakcfrumgczl", "unnmgrejgrdhyhtlnotakcfrumgcua", "unnmgrejgrdhyhtlnotakcfrumgcbz",
+ "unnmgrejgpk", "unnmgrejgrdhyhtlnotakcfrumgcnr", "unnmgrejgrdhyhtlnotakcfrumgcjt",
+ "unnmgrejgrdhyhtlnotakcfrumgcff", "unnmgrejgrdhyhtlnotwpzl", "unnmgrejgrdhyhtlnotakcfrumgcd",
+ "unnmgrejgrdhyhtlnotakcfrumgcxl", "unnmgrejgrdhyhtlnotakcfrumgcrj", "unnmgrejgrdhyhtlnotakcfrumgcgi",
+ "unnmgrejgrdhyhtlnotakcfrumgcsf", "unnmgrejgrdhyhtlnotakcfrumgcrr", "unnmgrejgrdhyhtlnotakcfrumgcfx",
+ "unnmgrejgrdhyhtlnotakcfrumgcwf", "unnmgrejgrdhyhtlnotalbsklsmt", "unnmgrejgrdhyhtlnotakcfrumgcwv",
+ "unnmgrejgrdhyhtlnotakcfywyfs", "unnmgrejgrdhyhtlnotakcfrumszn", "unnmgrejgrdhyhtlnotakcfrumgcsc",
+ "unnmgrejgrdhyhtlnotakcfrumgkm", "unnmgrejgrdhyhtlnotakcfrumgcgy", "unnmgrejgrdhyhtlnotakcfrumgcac",
+ "unnmgrejgrdhyhtlnotakcfrumgcil", "unnmgrejgrdhyhtlnotakcfrumgczb", "unnmgrejgrdhyhtlnotakcfrumgcrm",
+ "unnmgrejgrdhyhtlnotakcfrumgcnk", "ukqeym", "unnmgrejgrdhyhtlnotakcfrumgceh", "unnmgrejgrdhyhtlnotakcfrumgcak",
+ "unnmgrejgrdhyhtlnotakcfrhhdbw", "unnmgrejgrdhyhtlnotakcfrumgcvl", "unnmgrejgrdhyhtlnotakcfrumgr",
+ "unnmgrejgrdhyhtlnotakcfrumgcqa", "unnmgrejgrdhyhtlnotakcfrumgcns", "unnmgrejgrdhyhtlnotakcfrumgcbq",
+ "unnmgrejlyvqfzhalhvcmljzswvub", "unnmgrejgrdhyhtlnotrmtcwcphyy", "unnmgrejgrdhyhtlnotakcfrumgcpe",
+ "unnmgrejgrdhyhtlnotakcfrumgcyj", "unnmgrejgrdhyhtlnotakcfrumgcjs", "unnmgrejgrdhyhtlnotakcfrumgcwc",
+ "unnmgrejgrdhyhtlnotakcfrumgcno", "unnmgrejgrdhyhtlnos", "unnmgrejgrnpdx", "unnmgrejgrdhyhtlnotakcfrumgccg",
+ "unnmgrejgrdhyhtlnotakcfrumgcrc", "unnmgrejgrdhyhtlnotakczqdndk", "unnmgrejgrdhyhtlnotakcfrumgcuh",
+ "unnmgrejgrdhyhtlnotakcfrumgccs", "unnmgrejgrdhyhtlnotakcfrumgcmj", "unnmgrejgrdhyhtlnotakcfrumgclj",
+ "unnmgrejgsnnirkv", "unnmgrej", "ujcaoawifxy", "unnmgrejgrdhyhtlnjfyecozuou", "unnmgrejgrdhyhtlnotakcfrumgcpl",
+ "unnmgrejgrdhyhtlnotakcfrumrjx", "unnmgrejgrdhyhtlnotakcfrumgcws", "unnmgrejgrdhyhtlnotakcfrumgcek",
+ "unnmgrejgrdhyhtlnotakcfrumgcbd", "unnmzpromreensmkblv", "unnmgrejgrdhyhtlnotakcfrumgciv",
+ "unnmgrejgrdhyhtlnotakcfrumgcsx", "unnmgrudgvucgjlpdiijueghj", "unnmgrejgrdhyhtlnotakcfrumgcv",
+ "unnmgrejgrdhyhtlnotakcfrumgcpq", "unnmgrejgrdhyhtlnotakcfrumgcfp", "unnmgrejgrdhyhtlnotakcfrumgcqd",
+ "unnmgrejgrdhyhtlnotakcfrumgcul", "unnmgrejgrdhyhtlnotaroxeulx", "unnmgrejgrydscsgdou", "unnmgrejgrdhnegg",
+ "unnmgrejgrdhyhtlnotakcfrumgcfh", "unnmgrejgrdhyhtlnotakcfrumgcib", "unnmgrejgrdhyhtlnotakcfrumgcbe",
+ "unnmgrejgrdhyhtlnotakcfrumgct", "unnmgrejgrdhyhtlnotakcfrumgckp", "unnmgrejgrdhyhtlnotakcfrumgcph",
+ "unnmgrejgrdhyhtlnotakcfrumgck", "unnppqvsozeypffgs", "unnmgrejgrdhyhtqksdpfqk", "unnmgrejgrdhyhtlnotakcfrumgcde",
+ "unnmgrejgrdhyhtlnotakcfrumgcxz", "unnmgrejgrdhyhtlnotakcfrumgcyu", "unnmgrejgrdhyhtlnotakcfrumgclh",
+ "unnmgrejgrdhyhtlnotakcfrumgcis", "unnmgrejgrdhyhtlnotakcfrumgcnm", "unnmgrejgrdhyhtlnotakcfrumgctf",
+ "unnmgrejgrdhyhtlnotakcfrumgcbv", "unnmgrejgrdhyhtlnotakcfrxphm", "unnmgrejgrdhyhtlnotakcfrumgcys",
+ "unnmgrejgrdhyhtlnotakcfrumgcxb", "unnmgrejgrdhyhtlnotakcfrumgcsv", "unnmgrejgrdhyhtlnotakcfrumgchz",
+ "unnmgrejgrdhyhtlnotakcfrumgciz", "unnmgrejgrdhyhtlnotakcfrumgckv", "unnmgrejgrdhyhtlnotakcfrumgcpw",
+ "unnmgrejgrdhyhtlnotakcfrumgcxi", "unnmgrejgrdhyhtlnotakcfrumgcxs", "unnmgrejgrdhyhtlnotakcfrumgcho",
+ "unnmgrejgrdhyhtlnotakcfrumgcck", "unnmgrejgrdhyhfpktehqte", "unnmgrejgrdhyhtlnotakcfrumgckc",
+ "unnmgrejgrdhyhtlnotakcfrumgcqi", "unnmgrejgrdhyhtlnotakcfrumgcpi", "unnmgrejgrdhyhtlnotakcfrumgcyd",
+ "unnmgrejgrdhyhtlnotakcfrumgcpj", "unnmgrejgrdhyhtlnotakcfrumgcr", "unnmgrejgrdhyhtlnotakcfrumgcve",
+ "unnmgrejgrdhyhtlnotakcfrumgcbb", "unnmgrejgrdhyhw", "unnmgrejgrdhyhtlnotakcfrumgcnv",
+ "unnmgrejgrdhyhtlnotakcfrumgcut", "unnmgrejgrdhyhtlnotakcfrumgckz", "unnmgrejgrdhyhtlnotakcfrumgcod",
+ "unnmgrejgrdhyhtlnotakcfrumgcvh", "unnmgrjycqjafaykapibeny", "unnmgebvrlxccz", "unnmgrejgrdhyhtlnotakcfrumgcxx",
+ "unnmgrejgrdhyhtlnotakcfrumgcqb", "unnmgrejgrdhyhtlnotakcfrumgcas", "unnmgrejgrdhyhtlnotakcfrumgcva",
+ "unnmgrejgrdhyhtlnotakcfrumgccw", "unnmgrejgrdhyhtlnotakcfrumgcao", "unnmgrejgrdhyhtlnotakcfrumgcf",
+ "unnmgrejgrdhyhtlnotakcfrumgclm", "unnmgrejgrdhyhtlnotakcfrumgctp", "unnmgrejgrdhyhtlnotakcfrumgcpx",
+ "unnmgrejgrdhyhtleed", "unnmgrejgmtoyjezwedqblnb", "unnmgrejgrdvnhpigjnwkwgoytzetx", "unnmgrejgrdhyhzfdjqi",
+ "unnmgrejgrdhyhtlnotakcfrumgcta", "unnmgrejgrdhyhtlnotakcfrumgcxa", "unnmgriednpasskcoql",
+ "unnmgrejgrdhyhtlnotakcfrumgchg", "unnmgrejgrdhyhtlnotakcfrumgclg", "unnmgrejgrdhyhtlnotakcfrumgchl",
+ "unnmgrejgrdhyhtlnotakcfru", "unnmgrejgrdhyhtlnotakcfrumgcgl", "unnmgrejgranmdoswgepkuht",
+ "unnmgrejgrdhyhtlnotakcfrumgcjo", "unnmgrejgrdhyhtlnotakcfrumgcez", "unnmgrejgrdhyhtlnotakcfrumiab",
+ "unnmgrejgrdhyhtlnotakcfrumgcoz", "unnmgrejyjkryslhwwuujfatznm", "unnmgrejgrdh", "unnmgrejgrdhyhtlnotakcfrumgcqc",
+ "unnmgrejgrdhyhtlnotakcfrumgchj", "unnmgrejgrdhyhtlnotakcfrumgccx", "unnmgrejgrdhyhtlnotakcfrumgcyc",
+ "unnmgrejgrdhyhtlnotakcfrumgclv", "unnmgrtfbu", "unnmgrejg", "unnmgrejgrdhyhtlnotakcfrumgcn",
+ "unnmgrejgrdhyhtlnotakcfrumgcrh", "unnmgrejgrdhyhtlnotakcfrumgcsp", "unnmgrejgrdhyhtlnotakjmx",
+ "unnmgrejgrdhyhtlnotakcfrumgccf", "unnmgrejgrdhyhtlnotakcfrumgcyx", "unnmgrejgrdhyhtlnotakcfrumgcvf",
+ "unnmgrejgrdhyhtlnotakcfrumgckf", "unnmgrejgrdhyhtlnotakcfrumgcrx", "unnmgrejdxkvuvkmpxozzwwcpiyo",
+ "unnmgrejgrdhyhtlnotakcfrumgcor", "unnmgrejgrdhyhtkvswyemrnzc", "unnmgrejgrdhyhtlnotakcfrumgcuj",
+ "unnmgrejgrdhyhtlnojg", "unnmgrejgrdhyhtlnotakcfrumgcms", "unnmgre", "unnmgrejgrdhyhtlnotakcfrumgcaf",
+ "unnmgrejgrdhyhtlnotakcfrumgckl", "unnmgrejgrdhyhtlnotakcfrumgcbm", "unnmgrejgrdhyhtlnotakcfrumgcbn",
+ "unnmgrejgrdhyhtlnotakcfrumgcsx", "unnhijigjqsdslpbkindh", "unnmgrejgrdhyhtlnotakcfrumgccd",
+ "unnmgrejgrdhyhtlnotakcfrumgcwi", "unnmgrejgrdhyhtlnotakcfrumgcex", "unnmgrejgrdhyhtlnotakcfruwu",
+ "unnmgrejgrdhyhtlnotakcfrumgceg", "unnmgrejgrdhyhtlnotakcfrumgchx", "unnmgrejgrdhyhtlnotakcfrumgcye",
+ "unnmgrejgrdhyhtlnotakcfrumgcgm", "unnmgrejgrdhyhtlnotakcfrgdtva", "unnmgrejgrdhyhtlnotakcfrumgcq",
+ "unnmgrejgrdhyhtlnotakcfrumgcih", "unnmgrejgrdhyhtpqmsawnaldkbpal", "unnmgrejgrdhyhtlnotakcfrumgcoy",
+ "unnmgrejgrdhyhtlnotakcfrumgcar", "un", "unnmgrejgrdhyhtlnotakcfrumgcxw", "unnmgrejgrdhyhtlnotakcvpurjlyf",
+ "unnmgrejgrdhyhtlnotakcfrumgcsh", "unnmgrejgrdhyhtlnotakcfrumgcfb", "unnmgrejgrdhyhtlnotakcfrumgcfg",
+ "unnmgrejgrdhyhtlnotakcfrumgcxc", "unnmgrejgrdhyhtlnotakcfrumgcvd", "unnmgrejgrdhyhtlnotakcfrumgckm",
+ "unnmgrejgrdhyhtlnotah", "unnmgrejgrdhyhtlnotakcfrumgcln", "unnmgrejgrdhyhtlnotakcfrumgcow",
+ "unnmgrejguvxajmfzlabypdqa", "unnmgrejgrdhyhtlnotakcfrumgcfz", "unnmgrejgrdhyhtlnotakcfrumgcfs",
+ "unnmgrejgrdhyhtlnot", "unnmgrejgrdhyhtlnotakcfrumgcdy", "unncavnigadfjammkonpydmy", "unnmgrejgrdhyhqphfswzijde",
+ "unnmgrejgrdhyhtlnotakkpphfvfo", "unnm", "unnmgrejgrdhyhtlnotakcfrumgcxq", "unnmgrejgrdhyhtlnotakcfrumgcha",
+ "unnmgrejgrdhyhtlnotakcfrumgcsa", "unnmgrejgrdhyhtlnotakcfrumgcrd", "unnmgrejgrdhyhtlnotakcfrumgclb",
+ "unnmgrejgrdhyhtlnotakcfrumgcmw", "unnmgrejgrdhyhtlnotakcfrumgci", "unnmgrejgrdhyhtlnotakcfrumgczq",
+ "unnmgrejgrdhyhtlnotakcfrumgcrz", "unnmgrejgrdhyhtlnotakcfrumgces", "unnmgrejgrdhyhtlnotakcfrumgcmt",
+ "unnmgrejgrdhyhtlnotakcfrumgczz", "unnmgrejgrdhyhtlnotakcfrumgchm", "unnmgrejgrdhyhtlnotakcfrumgcdw",
+ "unnmgrejgrdhyhtlnotakcfrumgcgc", "unnmgrejgrdhyhtlnotakcsexkock", "unnmgrejgrdhyhtlnotakcfrumgu",
+ "unnmgrejgrdhyhtlnotakcfrumgcze", "unnmgrejgrdhyhtlnotakcfrumgctx", "unnmgrejgrdhyhtlnotakcfrumgcgp",
+ "unnmgrejgrdhyhtlnotakcfrumgcxn", "unnmgrejgrdhyhtlnfvjomwptova", "unnmgrejgrdhyhtlnotakcfrumgcwe",
+ "unnmgrejgrdhyhtlnotakcfrumgcgu", "unnmgrejgrdhyhtlnotakcfrumgcit", "unnmgrejgrdhyhtlnotakcfrumgcdh",
+ "unnmgrejgrdhyhtlnotakcfrumgcjm", "unnmgrejgrdhyhtlnotakcfrumgcso", "unnmgrejgrdhyhtlnotakcfrumgcui",
+ "unnmgrejgrdhyhtlnotakcfrumgclp", "unnmgrejgrdhyhtlnotakcfrumgcnn", "unnmgrejgrdhyhtlnotakcfrumgcau",
+ "unnmgrejgrdhyhtlnotakcfrumgcdj", "unnmgrejgrdhyhtlnotakcfrumgcbt", "unnmgrejgrdhyhtlnotakcfrumgcsk",
+ "unnmgrejgrdhyhtlnotakcfrumgcda", "unnmgrejgrdhyhtlnotakcfrumgcwu", "unnmgrejgrdhyhtlnotakcfrumgcqj",
+ "unnmgrejyfypdastivqvpmmmuwcqz", "unnmgrejgrdhyhtlnotakcfrumgcfl", "unnmgrejgrdhyhtlnotakcfrumgcnc", "unjbnr",
+ "unnmgrejgrdhyhtlnotakcfrumgcft", "unnmgrejgrdhyhtlnotakcfrumgcrw", "unnmgrejgrdhyhtlnotakcfrumgcnl",
+ "unnmgrejgrdhyhtlnotakcfrumgcsn", "unnmgrejgrdhyhtlhegi", "unnmgrejgrdhyhtlnotakcfrumgcxv",
+ "unnmgrejgrdhyhtlnotakcfrumgcew", "unnmgrejgrdhyhtln", "unnmgrejgrdhyhtlnotakcfrumgcjb", "unnmgnvvdurlowdmeotrb",
+ "unnmgrejgrdhyhtlnotakcfrumgcww", "unnmgrejgrdhyhtlnotakcfrumgcni", "unnmgrejgrdhyqeqwqtc",
+ "unnmgrejgrdhyhtlnotakcfrufokd", "unnmgrejgrdhyhtltbqlfb", "unnmgrejgrdhyhtlnotakcfrumgcbl",
+ "unnmgrejgrdhyhtlnotakcfrumgcjq", "unnmgrejgrdhyhtlnotakcfrumgcxe", "unnmgrejgrdhyhtlnotakcfrumgcdg", "unn",
+ "unnmgrejgrdhyhtlnotakcfrumgcbw", "unnmgrejgrdhyhtlnotakcfrumgcjv", "unnmgrejgrdhyhtlnotakcfrumgcgr",
+ "unnmgrejgrdhyhtlnotakcfruawulv", "unnmgrejgrdhyhtlnotakcfrwne", "unnmgrejgrdhyhtlnotakcfrumgcap",
+ "unnmgrejgrdhyhtlnotakcfrumgczw", "unnmgrejqjuiqmpknlnoeufr", "unnmgrejgrdhyhtal", "unnmgrejgrdhyhtlnotakcfr",
+ "unnmgrejgrdhyhtlnotakcfrumgcet", "unnmnvxgduagdze", "unnmgrejgrdhyhtlnotakcfrumgcer", "unnv",
+ "unnmgrejgrdhyhtlnotakcfrumgccl", "unnmgrejgrdhyhtlnotakcfrumgca", "ooq", "unnmgrejgrdhyhtlnotakcfrumgclc",
+ "unnmgrejgrdhyhtlnotakcfrumgcwt", "unnmgrfpfy", "unnmgrejgrdhyhtlnotak", "unnmgrejgrdhyhtlnotakcfrumgchd",
+ "unnmgrejgrdhyhtlnotakcfrumgcgs", "unnmgrejgrdhyhtlnotakcfrumgcbk", "unnmgrejgrdhyhtlnvemzl",
+ "unnmgrejgrdhyhtlnotakvmsozm", "unnmgrejgrdhyhtlnotakcfrumgczx", "unnmgrejgrdhyhtlnotakcfrumgcxf",
+ "unnmgrejgrdhyhtlnotakcfrumgccr", "unnmgrejgrdhyhtlnotakcfrumgcie", "unnmgrejgrdhkjiqj",
+ "unnmgrejgrdhyhtlnotakcfrumgcs", "unnmgrejgrdhyhtlnotakcfrumgcdf", "unnmgrejgrdhyhtlnotakcfrumgcmy",
+ "unnmgrejgrdhyhtlnotakcfrumgcjn", "unnmgrejgrdhyhtlnotakcfrumgcwy", "unnmgrejgrdhyhtlnotakcfrumgcbu",
+ "unnmgrejgrdhyhtlnotakcfrumgcru", "unnmgrejgrdhyhtlnotakcfrumgcb", "unnmgrejgrdhyhtlnotakcfrumgcsu",
+ "unnmgrejgrdhyhtlnotakcfrumgclr", "unnmgrejgrdhyhtlnotcurjdwusi", "unnmgrejgrdhyhtlnotakcfrumgcah",
+ "unnmgrejgrdhyhtlnotakcfrumgcpm", "ugjdkpvylidshorcdmy", "unnmgrejgrdhyhtlnotakcfrumgcz",
+ "unnmgrejgrdhyhtlnotakcfrumgcvk", "unnmgrejgrdhyhtlnotakcfrumgcjx", "unnmgrejgrdhyhtlnotakcfrumgcey",
+ "unnmgrejgrdhyhtlnotakcfrumgcqq", "unnmgrejgrdhyhtllaoqjqtonthq", "unnmgrejgrdhyhtlnotakcfrumgcti",
+ "unnmgrejgrdhyhtlnotakcfrumgcyk", "unnmgrejgrdhyhtlnotakcfrumgcal", "unnmgrejgrdhyhtlnotakcfrumgcre",
+ "unnmgrejgrdhyhtlnotakcfrumgcra", "unnmgrejgrdhyhtlnotakcfrumgcqm", "unnmgrejgrdhyhtlnotakcfrumgcbo",
+ "unnmgrejgrdhyhtlnotakcfrumgcdz", "unqqjfeuixcefq", "unnmgrejgrdhyhtlnotakcfrumgcko",
+ "unnmgrejgrdhyhtlnotakcfrumgcmp", "unnmgrejgrdhyhtlnotakcfrumgczy", "unnmgrejgrdhyhtlnotakcfrumgj",
+ "unnmgrejgrdhyhtlnotakcfrumgch", "unnmgrejgrdhyhtlnotakcfrumgctb", "unnmgrejgrdhyhtlnotakcfrumgciw",
+ "unnmgrejgrdhyhtlnotakcfrumgcvb", "unnmgrejgrdhyhtlnota", "unnmgregbysgbuajvoyerlkqhyhfty",
+ "unnmgrejgrdhyhtlnotakcfrumgcgz", "unnmgrejgrdhyhtlnotakcfrumgccv", "unnmgrejgrdhyhtlnotakcfrumgcxg",
+ "unnmgrejgrdhyhtlnotakcfrumgcri", "unnmgrejgrdhyhtlnotakcfrumgctt", "unnmgrejgrdhyhtlnotakcfrumgcen",
+ "unnmgrejgrdhyhtlnotakcfrumgcna", "unnmgrejgrdhyhtlnottusaco", "unnmgrejgrdhyhtlnotakcfrumgchi",
+ "unnmgrejgrdhyhtlnotakcfrumgclt", "unnmgrejgrdhyhtlnotakcfrumgcfk", "unnmgrejgrdhyhtlnotakcfrumgchu",
+ "unnmgrejgrdhyhtlnotakcfrumgcmz", "unnmgrejgrdhyhtlnotakcfrumgcpc", "unnmgrejgrdhyhtlnotakcfrumgcbr",
+ "unnmgrejgrdhyhtlnotakcfrumgcnb", "unnmgrejgrdhyhtlnotakcfrumgcyp", "unnmgrejgrdhyhtlnotakcfrumgcdk",
+ "unnmgrejgrdhyhtlnotakcfrumgczt", "unnmgrejgrdhyhtlnotakcfrumgtl", "unnmgrejgrdhyhtljssmaergclgwds",
+ "unnmgrejgrdhyhtzogzlakba", "unnmgrejgrdhyhtlnotakcfrumgcsb", "unnmgrejgrdhytlmxmdiyt",
+ "unnmgrejgrdhyhtlnotakcfrumgczp", "unnmgrejgrdhyhtlnotakcfrumgcza", "unnmgrehygumnsieeegycfkqshdu",
+ "unnmgrejgrdhyhtlnotakcfrumgcry", "unnmgrejgrdhyhtlnotakcfrumgcwq", "unnmgrejgrdhyhrqahifvtbvghja",
+ "unnmgrejgrdhyhtlnotakcfrumgctr", "unnmgrejgrdhyhtlnotakcpekpz", "unnmgrejgrdhyhtlnotakcfrumgcvm",
+ "unnmgrejgrdhyhtlnotakcfrumgcuc", "unnmgrejgrdhyhtlnotakcfrumgcvp", "unnmgrejgrdhyhtlnotakcfrumgcim",
+ "unnmgrejgrdhyhtlnotakcfrumgcnp", "unnmgrejgrdhyhtlnotakcfrumgclf", "unnmgrejgrdhyhtlnotakcfrumgcip",
+ "unnmgrejgrdhyhtlnotakcfrumgcch", "unnmgrejgrdhyhtlnotakcfrumgceb", "uy", "unnmgrejgrdhyhtlnotakcfrumgcoa",
+ "unnmgrejgrdhyhtlnotakcfrumgcmm", "unnmgrejgrdhyhtlnotakcfrumgcgn", "unnmgrejgrdhyhtlnotakcfrumgclq",
+ "unnmgrejgrdhyhtlnotakcfrumgcrg", "unnmgrejgrdhyhtlnotpxrjxhez", "unnmgrejgrdhyhtlnotakcfrumgcgt",
+ "unnmgrejgrdhyhtlnotakcfrumgcox", "unnmgrejgrdhyht", "unnmgrejgrdhyhtlnotakcfrumgcjg", "unnmgroxnk",
+ "unnmgrejgrdhyhtlnotakcfrumgyt", "unnmgrejgrdhyhtlnotakcfrumgcic", "unnmgrejgrdhyhtlnotakcfrumgctq", "unx",
+ "unnmgmzdwratt", "unnmgrejgrdhyhtlnotakcfrumgclk", "unnmgrejgrdhyhtlnotakcfrumgcaz", "unnmthlfg",
+ "unnmgrejgrdhyhtlnotakcfrumgcfo", "unnmgrejgrdhyhtlnotakcfrumgcpr", "unnmgrejgrdhyhtlnotakcfrumgcgw",
+ "unnmgrejgrdhyhtlnotakcfrumgcnz", "unnmgrejgrdhyhtlnotakcfrumgcdo", "unnmgrejgrdhyhtlnotakcfrumgcjf",
+ "unnmgrejgrdhyhtlnotakcfrumgcdi", "unnmgrejgrrtueahrax", "unnmgrejgrdhyhtlnotakcfrumgcbg", "tnohyrrwoler",
+ "unnmglzpcpxbuvrottj", "unnmgrejgrdhyhtlnotakcfrumgcvy", "unnmgrejgrdhyhtlnotakcfrumgcjy", "unnmgrejgrdhyhtorsq",
+ "unnmgrejgrdhyhtlnotakcfrumgctj", "unnmgrejgrdhyhtlnotakcfrumgcdw", "unnmgrejgrdhyhtlnotakcfrumgche",
+ "unnmgrejgrdhyhtlnotakcfrumgchc", "unnbaznjphnbfb", "unnmgrejgrdhyhtlnotakcfrumgcqp",
+ "unnmgrejgrdhyhtlnotakcfrumgcgv", "unnmgrejgrdhyhtbevyyvfgifad", "unnmgrejgrdhyhtlnotakcfrumgcky",
+ "unnmgrejgrdhyhtlnotakcfrumgcdr", "unnmgrejgrdhyhtlnotakcfrumgcub", "unnmgrejgrdhyhtlnotakcfrumgcm",
+ "unnmgrejgrdhyhtlnotakcfrumgcwm", "unnmgrejgrdhyhtlnotakcfrumgcro", "unnmgrejgrdhyhtlnotakcfrumgcjh",
+ "unnadhzmwyvjdq", "unnmgreevzcgzkxxzdgnlrugobphch", "unnmgrejgrdhyhtlnotakcfrumgcby",
+ "unnmgrejgrdhyhtlnotakcfrumgcvv", "unnmgrejgrdhyhtlnotakcfrumgcpp", "unnmgrejgrdhyhtlnotakcfrumgchp",
+ "unnmgrejgrdhyhtlnotakcfrumgcat", "unnmgrejgrdhyhtlnotakcfrumgcp", "unnmgrejgrdhyhtlnotakje",
+ "unnmgrejgrdhyhtlnotakcfrumgcii", "unnmgrejgrdhyhtlnotaufzaypqi", "unnmgrejgrdhyhtlnotakcfhf",
+ "unnmgrejgrdhyhtlnotakcfrumgcir", "unnmgrejgrdhyhtlnotakcfrumgcoi", "unnmgrejgrdhyhtlnotakcfrumgcaw",
+ "unnmgrejgrdhyhtlnotakcfrumgcwa", "unnmgrejgrdhyhtlnotakcfrumgcbi", "unnmgrejgrdhyhtlnotakcfrumgcfr", "ujmwoct",
+ "unnmgrejgrdhyhy", "unnmgrejgrdhyhtlnotakcfrumgcvr", "unnmgrejgrdhyhtlnotakcfrumgcfe", "unnmgrejgrdhyhtlnota",
+ "unnmgrejgrdhyhtlnotakcfrumgcpv", "unnmgrejgrdhyhtlnotakcfrumgczm", "unnmgrejgrdhyhtlnotakcfrumgcbi",
+ "unnwesyhllkrljgrsvfmb", "unnmgrejgrdhyhtlnotfopgljgyrk", "unnmgrejgrdhyhtlnotakcfrumgcpn",
+ "unnmgrejgrdhyhtlnotakcfrumgcur", "unnmgrejgrdhyhtlnotakcfrumgcoe", "unnmgrejgrdhyhtlnotakcfrumgcpd",
+ "unnmgrejgrdhyhtlnotakcfrumgcmh", "unnmgrejgrdhyhtlnotakcfrumgcai", "unnmgrejgrdhyhtlnotakcfrumgctn",
+ "unnmgrejgrdhyszjqda", "unnmgngmxgixgxsxlh", "unnmgrejgrdhyhtlnotakcfrumgcly", "unnmgrejgrdhyhtlnotakcfrumgcjw",
+ "unnmgrejgrdhyhtrtsuxpdswzrvl", "unnqahpbmswmk", "unnmgrejgrdhyhtlnotakcfrumgcsi",
+ "unnmgrejgrdhyhtlnotakcfrumgcyi", "unnmgrejgrdhyhtlnotakcfrumgcml", "unnmgrejgrdhyhtlnotakcfrumgcyf",
+ "unnmgrejgrdhyhtlnotakcfrumgcnh", "unnmgrejduxxzishhdmpa", "unnmgrejgrdhyhtlnotakcfrumgcbf",
+ "unnmgrejgrdhyhtlnotakcfrumgcyr", "unnmgrejgrdhyhtlnotakcfrumgcma", "unnmgrejgrdhyhtlnotakcfrumgcei",
+ "unnmgrejgrdhyhtlnotakcfrumgcjl", "unnmgrejgrdhyhtlnotakcfrumgcwj", "unnmgrejgrdhyhtlnotakcfrumgcix",
+ "unnmgrejgrdhyhtlnotakcfrumgcng", "unnmgrejgrdhydhkj", "unnmgrejgrdhyhtlnotakcfrumgckd",
+ "unnmgrejgrdhyhtlnotakcfrumgcyo", "unnmgrejgrdhyhtlnotakcfrumgctk", "unnmgrejgrdhyhtlnotakcfrumgcot",
+ "unnmgrejgrdhyhtlnotakcfrumgcxh", "unnmgrejgrdhyhtlnotakcfrumgcke", "unnmgrejgrdhyhtlnotakcfrumgcqt",
+ "unnmgrejgrdhyhtlnotakcfrumgcwn", "unnmgrejgrdhyhtlnotakcfrumgcfj", "unnmgrejgrdhyhtlnotakcfrumgcuw",
+ "unnmgrejgrdhyhtlnotakcfrumru", "unnmgrejgrdhyhtlnotakcfrumgcuy", "unnmgrejgrdhyhtlnotakcfrumgcmn",
+ "unbdbapznjavq", "unnmgrejgrdhyhtlnotakcfrumgcnu", "unnmgrejgrdhyhtlnotakcfrumgczu", "unnfeau",
+ "unnmgrejgrdhyhtlnotakcfrumgcik", "unnmgrejgrdhyhtlnotakcfrumgcty", "unnmgrejgrdhyhtlnotakcfrumgcll",
+ "unnmgrejgrdhyhtlnotakcfrumgcwh", "unnmgrejgkzkwiwncea", "unnmgrejgrdhyhtlnotakcfrumgcwl",
+ "unnmgrejgrdhyhtlnotakcfrumgckw", "unnmgrejgrdhyhtlnotakcfrumgcss", "unnmgrejgbymfoq",
+ "unnmgrejgrdhyhtlnotakcfrumgcju", "unnmgrejgrdhyhtlnotakcfrumgcts", "unnmgrejgrdhyhtlnotakcfrumgcqh",
+ "unnmgrejgrdhyhtlnotakcfrumgcht", "unnmgrejgrdhyhtlnotakcfrumgcqx", "unnmgrejgrpvifhhxvxdo",
+ "unnmgrejgrdhyhtlnotnloxwhtp", "unnmgrejgrdhyhtlnotakcfrumgcfc", "unnmgrejgrdhyhbjtp",
+ "unnmgrejgrdhyhtlnotakcfrumgcca", "unnmgrejgrdhyhtlnotakcfrumgcvw", "unnmgrejgrdhyhtlnotakcfrumgcmd",
+ "unnmgrejgrdhypsloh", "unnmgrejgrdhyhtlnotakcfrhag", "unnmgrejgrdhyhtlnotakmyhunlwru", "unnmgrejgrdhgcjazaxy",
+ "unnmgrejgrdhyhtlnotakcfrumgcid", "unnmgrejgrdhyhtlnotakcfrumgcw", "unnuan", "unnmgrejgrdhyhtlnotakcfrumgcfi",
+ "unnmgrejgrdhyhtlnotakcfrumgccy", "unnmgrejgrdhyhtlnotakcfrumgcej", "unnmgrejgrdhyhtlnotakcfrumgckq",
+ "unnmgrejgrdhyhtlnotakcfrumgcol", "unnmgrejgrdhyhtlnotakcfrumgcqv", "unnmgrejgrdhyhtlnotakcfrumgcg",
+ "unnmgrejgrdhyhtlnotakcfrumgcl", "unnmgrejgrdhyhtlnotakcfrumgcco", "unnmgrejgrdhyhtl",
+ "unnmgrejgrdhyhtlnotakcfrumgcbc", "unnmgrejgrdhyhtlnotakcfrumgcef", "unnmgrejgrdhyhtlnotakcfrumgcnw",
+ "unnmgrejgrdhyhtlnotakcfrumgcmk", "unnmgrejgrdhyhtlnotakcfrumgccj", "unnmgrejgrdhyhtlongzfhhaapd",
+ "unnmgrejgrdhyhtlnotakcfrumgcki", "unnmgrejgrdhyhtlnotakcfrumgccc", "unnmgrejgrdhyrvc",
+ "unnmgrejgrdhyhtlnotakcfrumgcsr", "unnmgrejgrdhyhtlnotasftxw", "unnmgrejgrdhyhtlnotakcfrumgcrv",
+ "unnmgrejgrdhyhtlnotakcfrumgcmx", "unnmgrejgrdhyhtlnotakcfrumgcga", "bwcsrcgsctlyudalyckkud",
+ "unnmgrejgrdhyhtlnotakcfrumgcij", "unnmgrejgrdhyhtlnor", "unnmgrejgrdhyhtlnotakcfrumgcmv",
+ "unnmgrejgrdhyamkqdaoooxmoszrb", "unnmgrejgrdhyhtlnotakcfrumgcuv", "unnmgrejgrdhyhtlnotanswtp",
+ "unnmgrejgrdhyhtlnotakcfrumgcrt", "unnmgrejgrdhyhtlnotakcfrumgcsq", "unnmgrejgrdhyhtlnotakcfrumgcvc",
+ "unnmlitobgnug", "lxppiyzvjtvchghycpprppmwunh", "unnmgrejgrdhyhtlnotakcfrumgcj", "unnmgrejgrdhyhtlnotakcfrumgcxk",
+ "unxmlewoxqitppybjkpqyyvxuqn", "unnmgrejgrdhyhtlnotakcfrumgcfq", "unnmgrejgrdhyhtlnotakcfrumgcoh",
+ "unnmgrejgrdhyhmgb", "unnmgrejgrdhyhtlnotakcnkpeij", "unnmgrejgrdhyhtlnotakcfrumgcdv",
+ "unnmgrejgrdhyhtlnotakcfrumgccz", "unnmgrejgrdhyhtlnotakcfrumgctc", "unnmgrejgrdhyhtlnotakcfrumgcrk",
+ "unnmgrejgrdhyhtlnotakcfrumgcsy", "unnmgrejgrdhyhtlnotakcfrumgcwx", "unnmgrejgrdhyhtlnotakcfrumgcfy",
+ "unnmgrejgrhl", "unnmgrejgrdhyhtlnotakcfrumgcec", "unnmgrejgrdhyhtlnotakcfrumgcsd",
+ "unnmgrejgrdhyhtlnotakcfrumgcya", "unnmgrejgrdhyhtlnotagrwb", "unnmgrejgrdhyhtlnotakcfrumgcwp",
+ "unnmgrejgrdhyhtlnotakcfrumgcji", "unnmgrejgrdhyhtlnvtgmosuo", "unnmgrejgrdhyhtlnotakcfrumgcbf",
+ "unnmgrejgrdhyhtlnotakcfrumgcmf", "unnmgrejgrdhyhtlnotakcfrumgcwg", "unnmgrejgrdhyhtlnotakcfrumgcan",
+ "unnmgrejgrdhyhtlnotakcfrumgcdt", "unnmgrejgrdhyhtlnotakcfrumgcuz", "unnmgrejgrdhyhtlnotakcfrumgcep",
+ "unnmgrejgrdhyhtlnotakcfrumgctg", "unnmgylmgdwoutwckudw", "unnmgrejgrdhyhtlnotakcfrumgcvt", "hcxraxlhemowtugjk",
+ "unnmgrejgrdhyhtlnotakcfrumgchb", "unnmgrejgrdhyhtlnotaktleiptkz", "unnmgrejgrdhyhtlnotakcfrumgcr",
+ "unnmgrejgrdhyhtlnotakcfrumgcbp", "unnmgrejgrdhyhtlnotakcfrumgcxt", "unnmgrejgrdhyhtlnotakcfrumgcpy",
+ "unnmgrejgrdhyhtlnotakcfrumgcyh"]))
diff --git a/Week_04/id_3/trie/LeetCode_720_3_v5.py b/Week_04/id_3/trie/LeetCode_720_3_v5.py
new file mode 100644
index 00000000..fa2f896f
--- /dev/null
+++ b/Week_04/id_3/trie/LeetCode_720_3_v5.py
@@ -0,0 +1,39 @@
+"""
+在v4的基础上进一步优化
+按字母正序 字母长度倒序
+这样可以更加稳准狠的剪枝
+======
+真是又简单又高效……
+O(nlogn)
+======
+打败了100%,值得纪念
+"""
+
+
+class Solution:
+ def longestWord(self, words):
+ if not words:
+ return ''
+ words_set = set(words)
+ words.sort()
+ words.sort(key=len, reverse=True)
+ for word in words:
+ w = word
+ while w in words_set:
+ w = w[:-1]
+
+ if len(w) == 0:
+ return word
+
+
+s = Solution()
+print(s.longestWord(["vsw", "vs", "zwu", "vsx", "nc", "o", "vswus", "orv", "imf", "i", "v", "zw", "vs"]))
+print(s.longestWord(["w", "wo", "wor", "worl", "world"]))
+print(s.longestWord(["a", "banana", "app", "appl", "ap", "apply", "apple"]))
+print(s.longestWord(["e", "el", "ele", "elep", "eleph", "elepha", "elephan", "elephant"]))
+print(s.longestWord(["ogz", "eyj", "e", "ey", "hmn", "v", "hm", "ogznkb", "ogzn", "hmnm", "eyjuo", "vuq", "ogznk", "og", "eyjuoi", "d"]))
+print(s.longestWord(["m", "mo", "moc", "moch", "mocha", "l", "la", "lat", "latt", "latte", "c", "ca", "cat"]))
+print(s.longestWord(["rac", "rs", "ra", "on", "r", "otif", "o", "onpdu", "rsf", "rs", "ot", "oti", "racy", "onpd"]))
+print(s.longestWord(
+ ["ts", "e", "x", "pbhj", "opto", "xhigy", "erikz", "pbh", "opt", "erikzb", "eri", "erik", "xlye", "xhig", "optoj",
+ "optoje", "xly", "pb", "xhi", "x", "o"]))
diff --git a/Week_04/id_3/trie/TrieTree.py b/Week_04/id_3/trie/TrieTree.py
new file mode 100644
index 00000000..f421d20e
--- /dev/null
+++ b/Week_04/id_3/trie/TrieTree.py
@@ -0,0 +1,26 @@
+import collections
+
+
+class TrieTree:
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def add(self, word):
+ node = self.root
+ for w in word:
+ node = node.edges[w]
+ node.letter = w
+ node.is_word = True
+
+
+class TrieNode:
+
+ def __init__(self):
+ self.edges = collections.defaultdict(TrieNode)
+ self.letter = None
+ self.is_word = False
+
+
+tree = TrieTree()
+tree.add('hello')
diff --git a/Week_04/id_40/LeetCode_208_40.cpp b/Week_04/id_40/LeetCode_208_40.cpp
new file mode 100644
index 00000000..ceb4a217
--- /dev/null
+++ b/Week_04/id_40/LeetCode_208_40.cpp
@@ -0,0 +1,93 @@
+/*
+ * @lc app=leetcode id=208 lang=cpp
+ *
+ * [208] Implement Trie (Prefix Tree)
+ *
+ * https://leetcode.com/problems/implement-trie-prefix-tree/description/
+ *
+ * algorithms
+ * Medium (39.02%)
+ * Likes: 1640
+ * Dislikes: 34
+ * Total Accepted: 184.5K
+ * Total Submissions: 472.8K
+ * Testcase Example: '["Trie","insert","search","search","startsWith","insert","search"]\n[[],["apple"],["apple"],["app"],["app"],["app"],["app"]]'
+ *
+ * Implement a trie with insert, search, and startsWith methods.
+ *
+ * Example:
+ *
+ *
+ * Trie trie = new Trie();
+ *
+ * trie.insert("apple");
+ * trie.search("apple"); // returns true
+ * trie.search("app"); // returns false
+ * trie.startsWith("app"); // returns true
+ * trie.insert("app");
+ * trie.search("app"); // returns true
+ *
+ *
+ * Note:
+ *
+ *
+ * You may assume that all inputs are consist of lowercase letters a-z.
+ * All inputs are guaranteed to be non-empty strings.
+ *
+ *
+ */
+const int MAXN = 26;
+class Trie {
+public:
+ /** Initialize your data structure here. */
+ bool is_str; // 标识当前结点是否为一个完整的字符串
+ Trie *next[MAXN]; // 下一个结点的指针数组
+ Trie() {
+ is_str = NULL;
+ memset(next,0,sizeof(next));
+ }
+
+ /** Inserts a word into the trie. */
+ void insert(string word) {
+ Trie *cur = this; // cur初始化为根结点指针
+ for(char w : word){ // 遍历word中的每一个字符
+ if(cur->next[w-'a']==NULL){ // 下一个结点不存在,新增一个结点
+ Trie *new_node = new Trie();
+ cur->next[w-'a'] = new_node;
+ }
+ cur = cur->next[w-'a'];
+ }
+ cur->is_str = true; // 当前结点已经是一个完整的字符串了
+
+
+ }
+
+ /** Returns if the word is in the trie. */
+ bool search(string word) {
+ Trie *cur = this;
+ for(char w : word){
+ if(cur!=NULL)
+ cur = cur->next[w-'a']; // 更新cur指针的指向,使其指向下一个结点
+ }
+ return (cur!=NULL&&cur->is_str); // cur指针不为空且cur指针指向的结点为一个完整的字符串,则成功找到字符串
+ }
+
+ /** Returns if there is any word in the trie that starts with the given prefix. */
+ bool startsWith(string prefix) {
+ Trie *cur = this;
+ for(char w : prefix){
+ if(cur!=NULL)
+ cur = cur->next[w-'a'];
+ }
+ return (cur!=NULL); // 相比search(),这里只需判断cur指针是否为空就行了
+ }
+};
+
+/**
+ * Your Trie object will be instantiated and called as such:
+ * Trie* obj = new Trie();
+ * obj->insert(word);
+ * bool param_2 = obj->search(word);
+ * bool param_3 = obj->startsWith(prefix);
+ */
+
diff --git a/Week_04/id_40/LeetCode_337_40.cpp b/Week_04/id_40/LeetCode_337_40.cpp
new file mode 100644
index 00000000..1f6ed8f4
--- /dev/null
+++ b/Week_04/id_40/LeetCode_337_40.cpp
@@ -0,0 +1,82 @@
+/*
+ * @lc app=leetcode id=337 lang=cpp
+ *
+ * [337] House Robber III
+ *
+ * https://leetcode.com/problems/house-robber-iii/description/
+ *
+ * algorithms
+ * Medium (48.27%)
+ * Likes: 1561
+ * Dislikes: 32
+ * Total Accepted: 105.9K
+ * Total Submissions: 219.4K
+ * Testcase Example: '[3,2,3,null,3,null,1]'
+ *
+ * The thief has found himself a new place for his thievery again. There is
+ * only one entrance to this area, called the "root." Besides the root, each
+ * house has one and only one parent house. After a tour, the smart thief
+ * realized that "all houses in this place forms a binary tree". It will
+ * automatically contact the police if two directly-linked houses were broken
+ * into on the same night.
+ *
+ * Determine the maximum amount of money the thief can rob tonight without
+ * alerting the police.
+ *
+ * Example 1:
+ *
+ *
+ * Input: [3,2,3,null,3,null,1]
+ *
+ * 3
+ * / \
+ * 2 3
+ * \ \
+ * 3 1
+ *
+ * Output: 7
+ * Explanation: Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.
+ *
+ * Example 2:
+ *
+ *
+ * Input: [3,4,5,1,3,null,1]
+ *
+ * 3
+ * / \
+ * 4 5
+ * / \ \
+ * 1 3 1
+ *
+ * Output: 9
+ * Explanation: Maximum amount of money the thief can rob = 4 + 5 = 9.
+ *
+ */
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ * int val;
+ * TreeNode *left;
+ * TreeNode *right;
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+ */
+class Solution {
+public:
+ int tryRob(TreeNode* root, int& l, int& r) {
+ if (!root)
+ return 0;
+
+ int ll = 0, lr = 0, rl = 0, rr = 0;
+ l = tryRob(root->left, ll, lr);
+ r = tryRob(root->right, rl, rr);
+
+ return max(root->val + ll + lr + rl + rr, l + r);
+ }
+
+ int rob(TreeNode* root) {
+ int l, r;
+ return tryRob(root, l, r);
+ }
+};
+
diff --git a/Week_04/id_40/LeetCode_53_40.cpp b/Week_04/id_40/LeetCode_53_40.cpp
new file mode 100644
index 00000000..1e106777
--- /dev/null
+++ b/Week_04/id_40/LeetCode_53_40.cpp
@@ -0,0 +1,68 @@
+/*
+ * @lc app=leetcode id=53 lang=cpp
+ *
+ * [53] Maximum Subarray
+ *
+ * https://leetcode.com/problems/maximum-subarray/description/
+ *
+ * algorithms
+ * Easy (43.84%)
+ * Likes: 4476
+ * Dislikes: 156
+ * Total Accepted: 555.6K
+ * Total Submissions: 1.3M
+ * Testcase Example: '[-2,1,-3,4,-1,2,1,-5,4]'
+ *
+ * Given an integer array nums, find the contiguous subarray (containing at
+ * least one number) which has the largest sum and return its sum.
+ *
+ * Example:
+ *
+ *
+ * Input: [-2,1,-3,4,-1,2,1,-5,4],
+ * Output: 6
+ * Explanation: [4,-1,2,1] has the largest sum = 6.
+ *
+ *
+ * Follow up:
+ *
+ * If you have figured out the O(n) solution, try coding another solution using
+ * the divide and conquer approach, which is more subtle.
+ *
+ */
+class Solution {
+public:
+/*
+ //暴力解法
+ int maxSubArray(vector& nums) {
+ if(nums.size()==0) return NULL;
+ int max=nums[0];//存最大值
+ int sum=0;//求和
+ for(int i=0;imax) max=sum;
+ }
+ }
+ return max;
+ }
+*/
+
+ //动态规划
+ int maxSubArray(vector& nums) {
+ if(nums.size() == 0) return NULL;
+ int res = INT_MIN;
+ int sum = -1;
+ for(int i = 0; i < nums.size(); ++i)
+ {
+ sum = max(nums[i], sum + nums[i]);
+ res = max(sum, res);
+ }
+ return res;
+ }
+
+};
+
diff --git a/Week_04/id_40/LeetCode_714_40.cpp b/Week_04/id_40/LeetCode_714_40.cpp
new file mode 100644
index 00000000..48378ca4
--- /dev/null
+++ b/Week_04/id_40/LeetCode_714_40.cpp
@@ -0,0 +1,53 @@
+/*
+ * @lc app=leetcode id=714 lang=cpp
+ *
+ * [714] Best Time to Buy and Sell Stock with Transaction Fee
+ *
+ * https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/description/
+ *
+ * algorithms
+ * Medium (50.65%)
+ * Likes: 934
+ * Dislikes: 31
+ * Total Accepted: 41K
+ * Total Submissions: 80.9K
+ * Testcase Example: '[1,3,2,8,4,9]\n2'
+ *
+ * Your are given an array of integers prices, for which the i-th element is
+ * the price of a given stock on day i; and a non-negative integer fee
+ * representing a transaction fee.
+ * You may complete as many transactions as you like, but you need to pay the
+ * transaction fee for each transaction. You may not buy more than 1 share of
+ * a stock at a time (ie. you must sell the stock share before you buy again.)
+ * Return the maximum profit you can make.
+ *
+ * Example 1:
+ *
+ * Input: prices = [1, 3, 2, 8, 4, 9], fee = 2
+ * Output: 8
+ * Explanation: The maximum profit can be achieved by:
+ * Buying at prices[0] = 1Selling at prices[3] = 8Buying at prices[4] =
+ * 4Selling at prices[5] = 9The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) =
+ * 8.
+ *
+ *
+ *
+ * Note:
+ * 0 < prices.length .
+ * 0 < prices[i] < 50000.
+ * 0 .
+ *
+ */
+class Solution {
+public:
+ int maxProfit(vector& prices, int fee) {
+ int s0 = 0, s1 = INT_MIN;
+ for(int p:prices) {
+ int tmp = s0;
+ s0 = max(s0, s1+p);
+ s1 = max(s1, tmp-p-fee);
+ }
+ return s0;
+ }
+};
+
diff --git a/Week_04/id_40/LeetCode_77_40.cpp b/Week_04/id_40/LeetCode_77_40.cpp
new file mode 100644
index 00000000..0f309672
--- /dev/null
+++ b/Week_04/id_40/LeetCode_77_40.cpp
@@ -0,0 +1,56 @@
+/*
+ * @lc app=leetcode id=77 lang=cpp
+ *
+ * [77] Combinations
+ *
+ * https://leetcode.com/problems/combinations/description/
+ *
+ * algorithms
+ * Medium (48.20%)
+ * Likes: 804
+ * Dislikes: 47
+ * Total Accepted: 208.5K
+ * Total Submissions: 432.6K
+ * Testcase Example: '4\n2'
+ *
+ * Given two integers n and k, return all possible combinations of k numbers
+ * out of 1 ... n.
+ *
+ * Example:
+ *
+ *
+ * Input: n = 4, k = 2
+ * Output:
+ * [
+ * [2,4],
+ * [3,4],
+ * [2,3],
+ * [1,2],
+ * [1,3],
+ * [1,4],
+ * ]
+ *
+ *
+ */
+class Solution {
+public:
+ vector> combine(int n, int k) {
+ vector> result;
+ int i = 0;
+ vector p(k, 0);
+ while (i >= 0) {
+ p[i]++;
+ if (p[i] > n)
+ --i;
+ else if (i == k - 1)
+ result.push_back(p);
+ else {
+ ++i;
+ p[i] = p[i - 1];
+ }
+ }
+ return result;
+
+ }
+};
+
diff --git a/Week_04/id_9/LeetCode_78_9.java b/Week_04/id_9/LeetCode_78_9.java
index 09358f28..45e96c72 100644
--- a/Week_04/id_9/LeetCode_78_9.java
+++ b/Week_04/id_9/LeetCode_78_9.java
@@ -21,11 +21,12 @@ public List> subsets(int[] nums) {
private void traverse(int[] nums, int index, List> list, List currentList) {
- //terminal
+ // terminator
if (nums.length == index) {
list.add(currentList);
return;
}
+
// process & drill down
List target = new LinkedList<>(currentList);