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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1560681524748 + + + 1560682106400 + + + 1560682222777 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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);