From 10fbffd57f52441c1ea3de3a7a469d8f1c0a9591 Mon Sep 17 00:00:00 2001 From: weipeng <624435565@qq.com> Date: Sun, 13 Oct 2019 10:39:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=84=91=E5=9B=BE=E5=92=8C=E6=80=BB?= =?UTF-8?q?=E7=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../id_451/NOTE.md" | 9 ++++++++- ...\346\225\260\346\215\256\347\273\223\346\236\2041.km" | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 "Week \351\242\204\344\271\240\345\221\250/id_451/\347\256\227\346\263\225\345\222\214\346\225\260\346\215\256\347\273\223\346\236\2041.km" diff --git "a/Week \351\242\204\344\271\240\345\221\250/id_451/NOTE.md" "b/Week \351\242\204\344\271\240\345\221\250/id_451/NOTE.md" index a6321d6e2..65c94c4ff 100644 --- "a/Week \351\242\204\344\271\240\345\221\250/id_451/NOTE.md" +++ "b/Week \351\242\204\344\271\240\345\221\250/id_451/NOTE.md" @@ -1,4 +1,11 @@ # NOTE - +# 学习方法 +用脑图整理知识点 +五遍刷题法 +leetcode 上通过国际战查看国际讨论 + +# 时间复杂度分析 +主定理 +根据n的值推断执行次数 diff --git "a/Week \351\242\204\344\271\240\345\221\250/id_451/\347\256\227\346\263\225\345\222\214\346\225\260\346\215\256\347\273\223\346\236\2041.km" "b/Week \351\242\204\344\271\240\345\221\250/id_451/\347\256\227\346\263\225\345\222\214\346\225\260\346\215\256\347\273\223\346\236\2041.km" new file mode 100644 index 000000000..56e661844 --- /dev/null +++ "b/Week \351\242\204\344\271\240\345\221\250/id_451/\347\256\227\346\263\225\345\222\214\346\225\260\346\215\256\347\273\223\346\236\2041.km" @@ -0,0 +1 @@ +{"root":{"data":{"id":"bxo1ako3r8g0","created":1570933059491,"text":"算法和数据结构"},"children":[{"data":{"id":"bxo1b5lr11k0","created":1570933105061,"text":"算法"},"children":[{"data":{"id":"bxo1gijx2fs0","created":1570933525070,"text":"动态规划"},"children":[]},{"data":{"id":"bxo1gmlukoo0","created":1570933533893,"text":"贪心"},"children":[]},{"data":{"id":"bxo1gphn8mw0","created":1570933540170,"text":"图论"},"children":[{"data":{"id":"bxo1h4oru000","created":1570933573252,"text":"最短路"},"children":[]},{"data":{"id":"bxo1h80z4sw0","created":1570933580521,"text":"最小生成树"},"children":[]},{"data":{"id":"bxo1hdsy1xc0","created":1570933593097,"text":"拓扑排序"},"children":[]}]},{"data":{"id":"bxo1huwflv40","created":1570933630312,"text":"遍历"},"children":[{"data":{"id":"bxo1i0epcs00","created":1570933642301,"text":"深度优先"},"children":[]},{"data":{"id":"bxo1i7utco00","created":1570933658512,"text":"广度优先"},"children":[]}]},{"data":{"id":"bxo1idg69ps0","created":1570933670688,"text":"排序"},"children":[{"data":{"id":"bxo1ikaxwr40","created":1570933685609,"text":"快速排序"},"children":[]},{"data":{"id":"bxo1inm3huo0","created":1570933692814,"text":"归并排序"},"children":[]},{"data":{"id":"bxo1it3sebs0","created":1570933704767,"text":"堆排序"},"children":[]}]}]},{"data":{"id":"bxo1b9bwr600","created":1570933113174,"text":"数据结构"},"children":[{"data":{"id":"bxo1bkrnl6w0","created":1570933138070,"text":"数组"},"children":[]},{"data":{"id":"bxo1br4v7l40","created":1570933151930,"text":"哈希表"},"children":[]},{"data":{"id":"bxo1bum0m7k0","created":1570933159497,"text":"链表"},"children":[]},{"data":{"id":"bxo1car68iw0","created":1570933194637,"text":"栈"},"children":[]},{"data":{"id":"bxo1chc8qlc0","created":1570933208972,"text":"二叉树"},"children":[{"data":{"id":"bxo1ctcly000","created":1570933235116,"text":"堆"},"children":[]},{"data":{"id":"bxo1g4n1uq80","created":1570933494785,"text":"avl树"},"children":[]},{"data":{"id":"bxo1g9yslyw0","created":1570933506378,"text":"红黑树"},"children":[]}]},{"data":{"id":"bxo1d4mozg80","created":1570933259670,"text":"图"},"children":[]}]}]},"template":"default","theme":"fresh-blue","version":"1.4.43"} \ No newline at end of file From 3d503adf2bbc3ef3e547c8b2090b32209c4894f5 Mon Sep 17 00:00:00 2001 From: weipeng <624435565@qq.com> Date: Sun, 20 Oct 2019 10:35:02 +0800 Subject: [PATCH 2/2] homework --- Week 01/id_451/LeetCode_26_451.go | 19 +++++++++++++++++++ Week 01/id_451/LeetCode_88_451.go | 23 +++++++++++++++++++++++ Week 01/id_451/NOTE.md | 12 +++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Week 01/id_451/LeetCode_26_451.go create mode 100644 Week 01/id_451/LeetCode_88_451.go diff --git a/Week 01/id_451/LeetCode_26_451.go b/Week 01/id_451/LeetCode_26_451.go new file mode 100644 index 000000000..1446ebd58 --- /dev/null +++ b/Week 01/id_451/LeetCode_26_451.go @@ -0,0 +1,19 @@ +func removeDuplicates(nums []int) int { + var pre, j int + for i, n := range nums { + if i == 0 { + pre = n + j = 1 + continue + } + if n == pre { + continue + } + + pre = n + nums[j] = n + j++ + } + return j +} + diff --git a/Week 01/id_451/LeetCode_88_451.go b/Week 01/id_451/LeetCode_88_451.go new file mode 100644 index 000000000..416a29051 --- /dev/null +++ b/Week 01/id_451/LeetCode_88_451.go @@ -0,0 +1,23 @@ +func merge(nums1 []int, m int, nums2 []int, n int) { + var i, j, k int + nums3 := make([]int, n+m) + if m == 0 || n == 0 { + copy(nums1, nums2) + return + } + for { + if k == n+m { + break + } + if j >= n || (nums1[i] < nums2[j] && i < m) { + nums3[k] = nums1[i] + k++ + i++ + continue + } + nums3[k] = nums2[j] + k++ + j++ + } + copy(nums1, nums3) +} diff --git a/Week 01/id_451/NOTE.md b/Week 01/id_451/NOTE.md index a6321d6e2..d9677f317 100644 --- a/Week 01/id_451/NOTE.md +++ b/Week 01/id_451/NOTE.md @@ -1,4 +1,14 @@ # NOTE +# 学习笔记 +# LRU 缓存 +通过hash表+链表实现 +通过hash表进行查找,通过双链表实现有序。 +# 跳跃表 +查询复杂度log(n) 插入删除复杂度log(n) +通过插入时随机选择level +# 优先队列 +抽象的数据结构,复杂度跟实现有关。(二叉堆) +# 代码点评 +通过学习256 同学的代码,学习到了合并有序数组此题的优化方法,(从尾端向前遍历,减少空间复杂度) -