From 28a87164acd41c32e7ef0668cd58091be113c735 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Tue, 23 Jun 2020 22:24:04 +0800 Subject: [PATCH 01/37] =?UTF-8?q?feat:=20=E6=9C=80=E9=95=BF=E5=9B=9E?= =?UTF-8?q?=E6=96=87=E5=AD=90=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\346\226\207\345\255\220\344\270\262-5.js" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" new file mode 100644 index 0000000..a7e91d7 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" @@ -0,0 +1,42 @@ +/** + * @param {string} s + * @return {string} + */ +let longestPalindrome = function (s) { + let n = s.length + if (n < 2) { + return s + } + + let dp = [] + for (let i = 0; i < n; i++) { + dp[i] = [] + dp[i][i] = true + } + + let max = 0 + let begin = 0 + for (let j = 1; j < n; j++) { + for (let i = 0; i < j; i++) { + if (s[j] !== s[i]) { + dp[i][j] = false + } else { + let indent = dp[i + 1][j - 1] + if (indent === undefined || indent === true) { + dp[i][j] = true + }else { + dp[i][j] = false + } + } + + if (dp[i][j] === true && j - i > max) { + max = j - i + begin = i + } + } + } + console.log('dp', dp) + return s.substr(begin, max + 1) +} + +console.log(longestPalindrome("abcda")) From c5f611e8bb55cbbd78b316275de11fb96c4267ef Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Wed, 24 Jun 2020 05:42:10 +0800 Subject: [PATCH 02/37] =?UTF-8?q?feat:=20=E6=9C=80=E9=95=BF=E5=9B=9E?= =?UTF-8?q?=E6=96=87=E5=AD=90=E4=B8=B2-=E4=B8=AD=E5=BF=83=E6=89=A9?= =?UTF-8?q?=E6=95=A3=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\346\226\207\345\255\220\344\270\262-5.js" | 85 +++++++++++++------ ...46\226\207\345\255\220\344\270\262-647.js" | 29 +++++++ 2 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 "\345\233\236\346\226\207\345\255\220\344\270\262-647.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" index a7e91d7..9876ba0 100644 --- "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\233\236\346\226\207\345\255\220\344\270\262-5.js" @@ -1,4 +1,47 @@ /** + * 动态规划 + * @param {string} s + * @return {string} + */ +// let longestPalindrome = function (s) { +// let n = s.length +// if (n < 2) { +// return s +// } + +// let dp = [] +// for (let i = 0; i < n; i++) { +// dp[i] = [] +// dp[i][i] = true +// } + +// let max = 0 +// let begin = 0 +// for (let j = 1; j < n; j++) { +// for (let i = 0; i < j; i++) { +// if (s[j] !== s[i]) { +// dp[i][j] = false +// } else { +// let indent = dp[i + 1][j - 1] +// if (indent === undefined || indent === true) { +// dp[i][j] = true +// }else { +// dp[i][j] = false +// } +// } + +// if (dp[i][j] === true && j - i > max) { +// max = j - i +// begin = i +// } +// } +// } +// console.log('dp', dp) +// return s.substr(begin, max + 1) +// } + +/** + * 中心扩散法 * @param {string} s * @return {string} */ @@ -8,35 +51,27 @@ let longestPalindrome = function (s) { return s } - let dp = [] - for (let i = 0; i < n; i++) { - dp[i] = [] - dp[i][i] = true - } - - let max = 0 let begin = 0 - for (let j = 1; j < n; j++) { - for (let i = 0; i < j; i++) { - if (s[j] !== s[i]) { - dp[i][j] = false - } else { - let indent = dp[i + 1][j - 1] - if (indent === undefined || indent === true) { - dp[i][j] = true - }else { - dp[i][j] = false - } - } + let max = 1 - if (dp[i][j] === true && j - i > max) { - max = j - i - begin = i + let spread = (start, end) => { + while (s[start] === s[end] && start >= 0 && end < n) { + let len = end - start + 1 + if (len > max) { + max = len + begin = start } + start-- + end++ } } - console.log('dp', dp) - return s.substr(begin, max + 1) + + for (let mid = 0; mid < n; mid++) { + spread(mid, mid) + spread(mid, mid + 1) + } + + return s.substr(begin, max) } -console.log(longestPalindrome("abcda")) +console.log(longestPalindrome("babad")) diff --git "a/\345\233\236\346\226\207\345\255\220\344\270\262-647.js" "b/\345\233\236\346\226\207\345\255\220\344\270\262-647.js" new file mode 100644 index 0000000..3a9c237 --- /dev/null +++ "b/\345\233\236\346\226\207\345\255\220\344\270\262-647.js" @@ -0,0 +1,29 @@ +/** + * @param {string} s + * @return {number} + */ +let countSubstrings = function (s) { + let n = s.length + if (n < 2) { + return n + } + + let count = 0 + + let spread = (start, end) => { + while (s[start] === s[end] && start >= 0 && end < n) { + start-- + end++ + count++ + } + } + + for (let mid = 0; mid < n; mid++) { + spread(mid, mid) + spread(mid, mid + 1) + } + + return count +} + +console.log(countSubstrings("a")) From b7d1eb39dde84debfc53f0f137bf642f9b45b988 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Thu, 25 Jun 2020 12:31:52 +0800 Subject: [PATCH 03/37] =?UTF-8?q?feat:=20=E5=8D=95=E8=AF=8D=E6=8B=86?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\257\215\346\213\206\345\210\206-139.js" | 25 ++++ ...42 II-212.Trie\347\211\210\346\234\254.js" | 112 ++++++++++++++++++ ...257\215\346\220\234\347\264\242 II-212.js" | 87 ++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206-139.js" create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.Trie\347\211\210\346\234\254.js" create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206-139.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206-139.js" new file mode 100644 index 0000000..dbb4672 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206-139.js" @@ -0,0 +1,25 @@ +/** + * @param {string} s + * @param {string[]} wordDict + * @return {boolean} + */ +let wordBreak = function (s, wordDict) { + let n = s.length + if (!n) return true + + let wordSet = new Set(wordDict) + let dp = [] + dp[0] = true + + for (let i = 0; i <= n; i++) { + for (let j = i; j >= 0; j--) { + let word = s.slice(j, i) + if (wordSet.has(word) && dp[j]) { + dp[i] = true + break + } + } + } + + return !!dp[n] +} diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.Trie\347\211\210\346\234\254.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.Trie\347\211\210\346\234\254.js" new file mode 100644 index 0000000..9032686 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.Trie\347\211\210\346\234\254.js" @@ -0,0 +1,112 @@ +/** + * Initialize your data structure here. + */ +var Trie = function () { + this.root = new TrieNode() +} + +var TrieNode = function () { + this.children = new Map() + this.isEnd = false +} + +/** + * Inserts a word into the trie. + * @param {string} word + * @return {void} + */ +Trie.prototype.insert = function (word) { + let node = this.root + + for (let i = 0; i < word.length; i++) { + let { children } = node + let trieNode = children.get(word[i]) + if (!trieNode) { + trieNode = new TrieNode() + children.set(word[i], trieNode) + } + node = trieNode + + if (i === word.length - 1) { + node.isEnd = true + node.word = word + } + } +} + +let dirs = [ + [0, 1], + [0, -1], + [-1, 0], + [1, 0], +] +/** + * @param {character[][]} board + * @param {string[]} words + * @return {string[]} + */ +let findWords = function (board, words) { + let maxY = board.length + if (!maxY) return [] + let maxX = board[0].length + + let rootTrie = new Trie() + for (let word of words) { + rootTrie.insert(word) + } + + // 记录已访问过的二维下标 + let visited = [] + for (let y = 0; y < maxY; y++) { + visited[y] = [] + } + + let isValid = (x, y) => { + return x >= 0 && x < maxX && y >= 0 && y < maxY && !visited[y][x] + } + + // 返回结果 + let res = [] + + let dfs = (x, y, trie) => { + let char = board[y][x] + let children = trie.children + let nextTrie = children && children.get(char) + if (nextTrie) { + if (nextTrie.word) { + res.push(nextTrie.word) + nextTrie.word = null + } else { + visited[y][x] = true + for (let dir of dirs) { + let [offsetY, offsetX] = dir + let nextY = y + offsetY + let nextX = x + offsetX + if (isValid(nextX, nextY)) { + dfs(nextX, nextY, nextTrie) + } + } + visited[y][x] = false + } + } + } + + for (let y = 0; y < maxY; y++) { + for (let x = 0; x < maxX; x++) { + if (y === 1 && x === 0) debugger + dfs(x, y, rootTrie.root) + } + } + + return Array.from(new Set(res)) +} + +console.log( + findWords( + [ + ["a", "b"], + ["a", "a"], + ], + ["aaba"] + ) +) diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.js" new file mode 100644 index 0000000..66d2f3d --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\215\225\350\257\215\346\220\234\347\264\242 II-212.js" @@ -0,0 +1,87 @@ +let dirs = [ + [0, 1], + [0, -1], + [-1, 0], + [1, 0], +] +/** + * @param {character[][]} board + * @param {string[]} words + * @return {string[]} + */ +let findWords = function (board, words) { + let maxY = board.length + if (!maxY) return [] + let maxX = board[0].length + + // 记录已访问过的二维下标 + let visited = [] + for (let y = 0; y < maxY; y++) { + visited[y] = [] + } + + let isValid = (x, y) => { + return x >= 0 && x < maxX && y >= 0 && y < maxY && !visited[y][x] + } + + // 返回结果 + let res = [] + + let dfs = (x, y, word, index) => { + let char = board[y][x] + let targetChar = word[index] + if (char === targetChar) { + if (index === word.length - 1) { + res.push(word) + } else { + visited[y][x] = true + for (let dir of dirs) { + let [offsetY, offsetX] = dir + let nextY = y + offsetY + let nextX = x + offsetX + if (isValid(nextX, nextY)) { + dfs(nextX, nextY, word, index + 1) + } + } + visited[y][x] = false + } + } + } + + let prefixMap = new Map() + for (let y = 0; y < maxY; y++) { + for (let x = 0; x < maxX; x++) { + let prefix = board[y][x] + let pos = prefixMap.get(prefix) + if (!pos) { + prefixMap.set(prefix, [[y, x]]) + } else { + prefixMap.set(prefix, [...pos, [y, x]]) + } + } + } + + let find = (word) => { + let head = word[0] + let pos = prefixMap.get(head) + if (pos) { + pos.forEach(([y, x]) => { + dfs(x, y, word, 0) + }) + } + } + + words.forEach(find) + + return Array.from(new Set(res)) +} + +console.log( + findWords( + [ + ["a", "b"], + ["a", "a"], + ], + ["aba", "baa", "bab", "aaab", "aaa", "aaaa", "aaba"] + ) +) From ed4deb88c5f0729c31342cc0bcb99a2e3d15cad3 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Thu, 25 Jun 2020 13:34:54 +0800 Subject: [PATCH 04/37] =?UTF-8?q?feat:=20=E4=B8=A4=E6=95=B0=E4=B9=8B?= =?UTF-8?q?=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\346\225\260\347\233\270\345\212\240-3.js" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240-3.js" diff --git "a/\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240-3.js" "b/\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240-3.js" new file mode 100644 index 0000000..9eec915 --- /dev/null +++ "b/\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240-3.js" @@ -0,0 +1,59 @@ +/** + * Definition for singly-linked list. + * function ListNode(val) { + * this.val = val; + * this.next = null; + * } + */ +/** + * @param {ListNode} l1 + * @param {ListNode} l2 + * @return {ListNode} + */ +let addTwoNumbers = function (l1, l2) { + let i = 0 + let root = new ListNode() + let cur = root + let plus = false + + let traverse = (node1, node2) => { + let isDouble = !!node2 + while (isDouble ? node1 && node2 : node1) { + cur.next = new ListNode() + cur = cur.next + + let sum = node1.val + (plus ? 1 : 0) + if (isDouble) { + sum += node2.val + } + + if (sum >= 10) { + sum %= 10 + plus = true + } else { + plus = false + } + cur.val = sum + + node1 = node1.next + if (isDouble) { + node2 = node2.next + } + } + + if (node1) { + traverse(node1) + } + if (node2) { + traverse(node2) + } + } + + traverse(l1, l2) + + if (plus) { + cur.next = new ListNode(1) + } + + return root.next +} From bbceee072bbab560d262e279657a1adb87baf21b Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Thu, 25 Jun 2020 16:35:36 +0800 Subject: [PATCH 05/37] =?UTF-8?q?feat:=20=E4=B8=A4=E6=95=B0=E7=9B=B8?= =?UTF-8?q?=E5=8A=A0=20II?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...225\260\347\233\270\345\212\240 II-445.js" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240 II-445.js" diff --git "a/\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240 II-445.js" "b/\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240 II-445.js" new file mode 100644 index 0000000..477c5a7 --- /dev/null +++ "b/\351\223\276\350\241\250/\344\270\244\346\225\260\347\233\270\345\212\240 II-445.js" @@ -0,0 +1,69 @@ +var reverseList = function (head) { + if (!head) return null + let res = null + let dfs = function (node) { + if (node.next) { + dfs(node.next) + node.next.next = node + } else { + res = node + } + } + + dfs(head) + + head.next = null + + return res +}; + +var addTwoNumbers = function (l1, l2) { + l1 = reverseList(l1) + l2 = reverseList(l2) + + let i = 0 + let root = new ListNode() + let cur = root + let plus = false + + let traverse = (node1, node2) => { + let isDouble = !!node2 + while (isDouble ? (node1 && node2) : node1) { + cur.next = new ListNode() + cur = cur.next + + let sum = node1.val + (plus ? 1 : 0) + if (isDouble) { + sum += node2.val + } + + if (sum >= 10) { + sum %= 10 + plus = true + } else { + plus = false + } + cur.val = sum + + node1 = node1.next + if (isDouble) { + node2 = node2.next + } + } + + if (node1) { + traverse(node1) + } + if (node2) { + traverse(node2) + } + } + + traverse(l1, l2) + + if (plus) { + cur.next = new ListNode(1) + } + + return reverseList(root.next) +}; From 62e73148edd3e0c24a6cf259d02daea79c15e572 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Thu, 25 Jun 2020 23:11:58 +0800 Subject: [PATCH 06/37] =?UTF-8?q?feat:=20=E5=8D=95=E8=AF=8D=E6=8B=86?= =?UTF-8?q?=E5=88=86=20II?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...350\257\215\346\213\206\345\210\206 II.js" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206 II.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206 II.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206 II.js" new file mode 100644 index 0000000..06c432a --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\345\215\225\350\257\215\346\213\206\345\210\206 II.js" @@ -0,0 +1,37 @@ +let wordBreak = function (s, wordDict) { + let uniqSChars = uniq(s.split("")) + let uniqWordDictChars = uniq(wordDict.join("")) + if (uniqSChars.length !== uniqWordDictChars.length) { + return false + } + + let n = s.length + if (!n) { + return [] + } + + let wordSet = new Set(wordDict) + let dp = [] + dp[0] = [""] + + for (let i = 1; i <= n; i++) { + let res = [] + for (let j = i; j >= 0; j--) { + let word = s.slice(j, i) + if (wordSet.has(word)) { + if (dp[j] && dp[j].length) { + for (let prev of dp[j]) { + res.push(prev ? prev + " " + word : word) + } + } + } + } + dp[i] = res + } + + return dp[n] +} + +function uniq(arr) { + return Array.from(new Set(arr)) +} From 622e9dafa3dee5a7419b17e27e3cb650e263da5b Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Fri, 26 Jun 2020 02:22:01 +0800 Subject: [PATCH 07/37] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E9=93=BE?= =?UTF-8?q?=E8=A1=A8=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...273\264\347\237\251\351\230\265 II-240.js" | 24 +++++++++++++++++++ ...50\241\250\345\205\203\347\264\240-203.js" | 18 ++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 "\345\217\214\346\214\207\351\222\210/\346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II-240.js" create mode 100644 "\351\223\276\350\241\250/\347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240-203.js" diff --git "a/\345\217\214\346\214\207\351\222\210/\346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II-240.js" "b/\345\217\214\346\214\207\351\222\210/\346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II-240.js" new file mode 100644 index 0000000..54f7a34 --- /dev/null +++ "b/\345\217\214\346\214\207\351\222\210/\346\220\234\347\264\242\344\272\214\347\273\264\347\237\251\351\230\265 II-240.js" @@ -0,0 +1,24 @@ +/** + * @param {number[][]} matrix + * @param {number} target + * @return {boolean} + */ +let searchMatrix = function (matrix, target) { + let y = matrix.length + if (!y) return false + let x = matrix[0].length + + let row = y - 1 + let column = 0 + while (row >= 0 && column < x) { + let val = matrix[row][column] + if (val > target) { + row-- + } else if (val < target) { + column++ + } else if (val === target) { + return true + } + } + return false +}; \ No newline at end of file diff --git "a/\351\223\276\350\241\250/\347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240-203.js" "b/\351\223\276\350\241\250/\347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240-203.js" new file mode 100644 index 0000000..bd16019 --- /dev/null +++ "b/\351\223\276\350\241\250/\347\247\273\351\231\244\351\223\276\350\241\250\345\205\203\347\264\240-203.js" @@ -0,0 +1,18 @@ +let removeElements = function (head, val) { + let root = new ListNode() + root.next = head + let cur = root + while (cur) { + let next = cur.next + if (!next) { + break + } + let nextVal = next.val + if (nextVal === val) { + cur.next = cur.next.next + } else { + cur = cur.next + } + } + return root.next +} From 660c789dc9c201b9404dd0a268504fa6f411c8dc Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Fri, 26 Jun 2020 14:37:18 +0800 Subject: [PATCH 08/37] Update README.md --- README.md | 403 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 403 insertions(+) diff --git a/README.md b/README.md index c2fd139..9b7fb9c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,409 @@ 思路会记录在本仓库的 Issues 中,按照 label 进行分类。比如想查看 「DFS」 分类下的问题,那么选择标签进行筛选即可。 +## 目录 +### 待复习 + +[移除链表元素-203](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/97) + +[搜索二维矩阵 II-240](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/96) + +[单词拆分-139](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/93) + +[最长回文子串-5](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/91) + +[无重叠区间-435](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/90) + +[目标和-494](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/87) + +[最长公共子序列-1143](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/85) + +[三角形最小路径和-120](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/80) + +[N皇后-51](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/78) + +[组合总和 II-40](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/73) + +[组合总和-39](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/72) + +[子集-78](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/71) + +[全排列-46](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/68) + +[复原IP地址-93](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/66) + +[电话号码的字母组合-17](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/65) + +[将有序数组转换为二叉搜索树](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/63) + +[删除二叉搜索树中的节点-450](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/62) + +[路径总和 III-437](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/61) + +[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) + +[对称二叉树-101](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/55) + +[两两交换链表中的节点-24](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/51) + +[二叉树的前序遍历-144](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/50) + +[找到字符串中所有字母异位词-438](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/44) + +[最小覆盖子串-76](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/43) + +[无重复字符的最长子串-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/42) + +[长度最小的子数组-209](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/36) + +[LRU 缓存机制-146](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/35) + +[括号生成-22](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/31) + +[合并两个有序数组-88](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/29) + +[移动零-283](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/26) + +[最大子序和-53](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/17) + +[背包(01背包)](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/15) + +### 链表 + +[移除链表元素-203](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/97) + +[两数相加-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/94) + +[两两交换链表中的节点-24](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/51) + +[删除链表的倒数第N个节点-19](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/46) + +[删除链表的节点-面试题18](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/40) + +[反转链表II-92](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/39) + +[反转链表 206](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/38) + +### 双指针 + +[搜索二维矩阵 II-240](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/96) + +[判断子序列-392](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/89) + +[分发饼干-455](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/88) + +[验证回文串-125](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/33) + +[两数之和 II - 输入有序数组-167](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/32) + +[合并两个有序数组-88](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/29) + +[移动零-283](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/26) + +[删除排序数组中的重复项-26](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/8) + +[盛水最多的容器-11](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/3) + +### 动态规划 + +[单词拆分 II-140](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/95) + +[单词拆分-139](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/93) + +[最长回文子串-5](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/91) + +[无重叠区间-435](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/90) + +[目标和-494](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/87) + +[一和零-474](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/86) + +[最长公共子序列-1143](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/85) + +[摆动序列-376](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/84) + +[最长上升子序列-300](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/83) + +[最长等差数列-1027](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/82) + +[解码方法-91](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/81) + +[三角形最小路径和-120](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/80) + +[最小路径和-64](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/34) + +[括号生成-22](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/31) + +[爬楼梯-70](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/22) + +[买卖股票的最佳时机-121](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/19) + +[乘积最大子数组-152](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/18) + +[最大子序和-53](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/17) + +[分割等和子集(01背包的变种)-416](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/16) + +[背包(01背包)](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/15) + +[使用最小花费爬楼梯-746](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/13) + +[零钱兑换 II-518](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/12) + +[打家劫舍 - 198](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/10) + +[完全平方数-279](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/9) + +[整数拆分-343](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/7) + +[斐波那契数-509](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/2) + +### 递归与回溯 + +[单词搜索 II-212](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/92) + +[解数独-37](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/79) + +[N皇后-51](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/78) + +[单词搜索-79](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/77) + +[二进制手表-401](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/76) + +[子集 II-90](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/75) + +[ 组合总和 III-216](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/74) + +[组合总和 II-40](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/73) + +[组合总和-39](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/72) + +[子集-78](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/71) + +[组合-77](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/70) + +[全排列 II-47](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/69) + +[全排列-46](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/68) + +[分割回文串-131](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/67) + +[复原IP地址-93](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/66) + +[电话号码的字母组合-17](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/65) + +### 贪心算法 + +[判断子序列-392](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/89) + +[分发饼干-455](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/88) + +[买卖股票的最佳时机 II-122](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/20) + +### 例题详解 + +[分发饼干-455](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/88) + +[N皇后-51](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/78) + +[单词搜索-79](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/77) + +[二进制手表-401](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/76) + +[电话号码的字母组合-17](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/65) + +[二叉树的所有路径-257](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/59) + +[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) + +[两两交换链表中的节点-24](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/51) + +[无重复字符的最长子串-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/42) + +[二分查找-704](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/23) + +[背包(01背包)](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/15) + +[盛水最多的容器-11](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/3) + +[斐波那契数-509](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/2) + +### DFS + +[二叉树的最近公共祖先-236](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/64) + +[将有序数组转换为二叉搜索树](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/63) + +[删除二叉搜索树中的节点-450](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/62) + +[路径总和 III-437](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/61) + +[求根到叶子节点数字之和-129](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/60) + +[二叉树的所有路径-257](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/59) + +[左叶子之和-404](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/58) + +[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) + +[平衡二叉树-110](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/56) + +[对称二叉树-101](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/55) + +[二叉树的最小深度-111](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/54) + +[二叉树的最大深度-104](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/53) + +[二叉树的层序遍历](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/30) + +[路径总和 II-113](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/27) + +[相同的树-100](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/21) + +[打家劫舍 |||-337](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/11) + +[被围绕的区域-130](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/6) + +[岛屿的最大面积-695](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/5) + +### 二叉树 + +[二叉树的最近公共祖先-236](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/64) + +[将有序数组转换为二叉搜索树](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/63) + +[删除二叉搜索树中的节点-450](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/62) + +[路径总和 III-437](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/61) + +[求根到叶子节点数字之和-129](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/60) + +[二叉树的所有路径-257](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/59) + +[左叶子之和-404](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/58) + +[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) + +[平衡二叉树-110](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/56) + +[对称二叉树-101](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/55) + +[二叉树的最小深度-111](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/54) + +[二叉树的最大深度-104](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/53) + +[二叉树的右视图-199](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/52) + +[二叉树的前序遍历-144](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/50) + +[二叉树的层序遍历](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/30) + +[路径总和 II-113](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/27) + +[相同的树-100](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/21) + +### BFS + +[二叉树的最小深度-111](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/54) + +[二叉树的最大深度-104](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/53) + +[二叉树的右视图-199](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/52) + +[二叉树的层序遍历](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/30) + +[相同的树-100](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/21) + +[在每个树行中找最大值-515](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/4) + +### 栈和队列 + +[二叉树的右视图-199](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/52) + +[二叉树的前序遍历-144](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/50) + +[简化路径-71](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/49) + +[有效的括号-20](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/48) + +[逆波兰表达式求值-150](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/47) + +### 滑动窗口 + +[滑动窗口的最大值-239](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/45) + +[找到字符串中所有字母异位词-438](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/44) + +[最小覆盖子串-76](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/43) + +[无重复字符的最长子串-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/42) + +[长度最小的子数组-209](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/36) + +### 排序 + +[快速排序](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/41) + +[颜色分类-75](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/28) + +### 查找表 + +[两个数组的交集 II-350](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/37) + +### 数据结构 + +[LRU 缓存机制-146](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/35) + +[实现 Trie (前缀树)-208](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/14) + +### 复习 * 1 + +[两数之和 II - 输入有序数组-167](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/32) + +[Pow(x, n)-50](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/25) + +[x 的平方根-69](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/24) + +[爬楼梯-70](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/22) + +[买卖股票的最佳时机 II-122](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/20) + +[买卖股票的最佳时机-121](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/19) + +[分割等和子集(01背包的变种)-416](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/16) + +[实现 Trie (前缀树)-208](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/14) + +[零钱兑换 II-518](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/12) + +[打家劫舍 |||-337](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/11) + +[删除排序数组中的重复项-26](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/8) + +[被围绕的区域-130](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/6) + +### 二分查找 + +[Pow(x, n)-50](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/25) + +[x 的平方根-69](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/24) + +[二分查找-704](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/23) + +### 复习 * 3 + +[乘积最大子数组-152](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/18) + +[最大子序和-53](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/17) + +### 复习 * 2 + +[打家劫舍 - 198](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/10) + +[整数拆分-343](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/7) + +[在每个树行中找最大值-515](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/4) + ## Author 👤 **ssh** From f36eb3081791984f1c9424f7e96ae151780c757a Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Fri, 26 Jun 2020 14:40:34 +0800 Subject: [PATCH 09/37] Update README.md --- README.md | 97 ------------------------------------------------------- 1 file changed, 97 deletions(-) diff --git a/README.md b/README.md index 9b7fb9c..0e2a61d 100644 --- a/README.md +++ b/README.md @@ -16,71 +16,6 @@ 思路会记录在本仓库的 Issues 中,按照 label 进行分类。比如想查看 「DFS」 分类下的问题,那么选择标签进行筛选即可。 ## 目录 -### 待复习 - -[移除链表元素-203](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/97) - -[搜索二维矩阵 II-240](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/96) - -[单词拆分-139](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/93) - -[最长回文子串-5](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/91) - -[无重叠区间-435](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/90) - -[目标和-494](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/87) - -[最长公共子序列-1143](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/85) - -[三角形最小路径和-120](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/80) - -[N皇后-51](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/78) - -[组合总和 II-40](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/73) - -[组合总和-39](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/72) - -[子集-78](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/71) - -[全排列-46](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/68) - -[复原IP地址-93](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/66) - -[电话号码的字母组合-17](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/65) - -[将有序数组转换为二叉搜索树](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/63) - -[删除二叉搜索树中的节点-450](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/62) - -[路径总和 III-437](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/61) - -[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) - -[对称二叉树-101](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/55) - -[两两交换链表中的节点-24](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/51) - -[二叉树的前序遍历-144](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/50) - -[找到字符串中所有字母异位词-438](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/44) - -[最小覆盖子串-76](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/43) - -[无重复字符的最长子串-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/42) - -[长度最小的子数组-209](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/36) - -[LRU 缓存机制-146](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/35) - -[括号生成-22](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/31) - -[合并两个有序数组-88](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/29) - -[移动零-283](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/26) - -[最大子序和-53](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/17) - -[背包(01背包)](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/15) ### 链表 @@ -370,32 +305,6 @@ [实现 Trie (前缀树)-208](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/14) -### 复习 * 1 - -[两数之和 II - 输入有序数组-167](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/32) - -[Pow(x, n)-50](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/25) - -[x 的平方根-69](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/24) - -[爬楼梯-70](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/22) - -[买卖股票的最佳时机 II-122](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/20) - -[买卖股票的最佳时机-121](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/19) - -[分割等和子集(01背包的变种)-416](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/16) - -[实现 Trie (前缀树)-208](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/14) - -[零钱兑换 II-518](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/12) - -[打家劫舍 |||-337](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/11) - -[删除排序数组中的重复项-26](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/8) - -[被围绕的区域-130](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/6) - ### 二分查找 [Pow(x, n)-50](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/25) @@ -404,12 +313,6 @@ [二分查找-704](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/23) -### 复习 * 3 - -[乘积最大子数组-152](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/18) - -[最大子序和-53](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/17) - ### 复习 * 2 [打家劫舍 - 198](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/10) From ee7eacb6f7bb18c3e714099fed3e0f2bdeb6291c Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Fri, 26 Jun 2020 14:44:39 +0800 Subject: [PATCH 10/37] Update README.md --- README.md | 275 ++++++++++++++++++++++++++---------------------------- 1 file changed, 133 insertions(+), 142 deletions(-) diff --git a/README.md b/README.md index 0e2a61d..a61690a 100644 --- a/README.md +++ b/README.md @@ -16,310 +16,301 @@ 思路会记录在本仓库的 Issues 中,按照 label 进行分类。比如想查看 「DFS」 分类下的问题,那么选择标签进行筛选即可。 ## 目录 - ### 链表 -[移除链表元素-203](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/97) +[移除链表元素-203](https://github.com/sl1673495/leetcode-javascript/issues/97) -[两数相加-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/94) +[两数相加-3](https://github.com/sl1673495/leetcode-javascript/issues/94) -[两两交换链表中的节点-24](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/51) +[两两交换链表中的节点-24](https://github.com/sl1673495/leetcode-javascript/issues/51) -[删除链表的倒数第N个节点-19](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/46) +[删除链表的倒数第N个节点-19](https://github.com/sl1673495/leetcode-javascript/issues/46) -[删除链表的节点-面试题18](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/40) +[删除链表的节点-面试题18](https://github.com/sl1673495/leetcode-javascript/issues/40) -[反转链表II-92](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/39) +[反转链表II-92](https://github.com/sl1673495/leetcode-javascript/issues/39) -[反转链表 206](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/38) +[反转链表 206](https://github.com/sl1673495/leetcode-javascript/issues/38) ### 双指针 -[搜索二维矩阵 II-240](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/96) +[搜索二维矩阵 II-240](https://github.com/sl1673495/leetcode-javascript/issues/96) -[判断子序列-392](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/89) +[判断子序列-392](https://github.com/sl1673495/leetcode-javascript/issues/89) -[分发饼干-455](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/88) +[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) -[验证回文串-125](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/33) +[验证回文串-125](https://github.com/sl1673495/leetcode-javascript/issues/33) -[两数之和 II - 输入有序数组-167](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/32) +[两数之和 II - 输入有序数组-167](https://github.com/sl1673495/leetcode-javascript/issues/32) -[合并两个有序数组-88](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/29) +[合并两个有序数组-88](https://github.com/sl1673495/leetcode-javascript/issues/29) -[移动零-283](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/26) +[移动零-283](https://github.com/sl1673495/leetcode-javascript/issues/26) -[删除排序数组中的重复项-26](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/8) +[删除排序数组中的重复项-26](https://github.com/sl1673495/leetcode-javascript/issues/8) -[盛水最多的容器-11](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/3) +[盛水最多的容器-11](https://github.com/sl1673495/leetcode-javascript/issues/3) ### 动态规划 -[单词拆分 II-140](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/95) +[单词拆分 II-140](https://github.com/sl1673495/leetcode-javascript/issues/95) -[单词拆分-139](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/93) +[单词拆分-139](https://github.com/sl1673495/leetcode-javascript/issues/93) -[最长回文子串-5](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/91) +[最长回文子串-5](https://github.com/sl1673495/leetcode-javascript/issues/91) -[无重叠区间-435](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/90) +[无重叠区间-435](https://github.com/sl1673495/leetcode-javascript/issues/90) -[目标和-494](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/87) +[目标和-494](https://github.com/sl1673495/leetcode-javascript/issues/87) -[一和零-474](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/86) +[一和零-474](https://github.com/sl1673495/leetcode-javascript/issues/86) -[最长公共子序列-1143](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/85) +[最长公共子序列-1143](https://github.com/sl1673495/leetcode-javascript/issues/85) -[摆动序列-376](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/84) +[摆动序列-376](https://github.com/sl1673495/leetcode-javascript/issues/84) -[最长上升子序列-300](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/83) +[最长上升子序列-300](https://github.com/sl1673495/leetcode-javascript/issues/83) -[最长等差数列-1027](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/82) +[最长等差数列-1027](https://github.com/sl1673495/leetcode-javascript/issues/82) -[解码方法-91](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/81) +[解码方法-91](https://github.com/sl1673495/leetcode-javascript/issues/81) -[三角形最小路径和-120](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/80) +[三角形最小路径和-120](https://github.com/sl1673495/leetcode-javascript/issues/80) -[最小路径和-64](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/34) +[最小路径和-64](https://github.com/sl1673495/leetcode-javascript/issues/34) -[括号生成-22](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/31) +[括号生成-22](https://github.com/sl1673495/leetcode-javascript/issues/31) -[爬楼梯-70](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/22) +[爬楼梯-70](https://github.com/sl1673495/leetcode-javascript/issues/22) -[买卖股票的最佳时机-121](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/19) +[买卖股票的最佳时机-121](https://github.com/sl1673495/leetcode-javascript/issues/19) -[乘积最大子数组-152](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/18) +[乘积最大子数组-152](https://github.com/sl1673495/leetcode-javascript/issues/18) -[最大子序和-53](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/17) +[最大子序和-53](https://github.com/sl1673495/leetcode-javascript/issues/17) -[分割等和子集(01背包的变种)-416](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/16) +[分割等和子集(01背包的变种)-416](https://github.com/sl1673495/leetcode-javascript/issues/16) -[背包(01背包)](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/15) +[背包(01背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) -[使用最小花费爬楼梯-746](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/13) +[使用最小花费爬楼梯-746](https://github.com/sl1673495/leetcode-javascript/issues/13) -[零钱兑换 II-518](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/12) +[零钱兑换 II-518](https://github.com/sl1673495/leetcode-javascript/issues/12) -[打家劫舍 - 198](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/10) +[打家劫舍 - 198](https://github.com/sl1673495/leetcode-javascript/issues/10) -[完全平方数-279](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/9) +[完全平方数-279](https://github.com/sl1673495/leetcode-javascript/issues/9) -[整数拆分-343](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/7) +[整数拆分-343](https://github.com/sl1673495/leetcode-javascript/issues/7) -[斐波那契数-509](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/2) +[斐波那契数-509](https://github.com/sl1673495/leetcode-javascript/issues/2) ### 递归与回溯 -[单词搜索 II-212](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/92) +[单词搜索 II-212](https://github.com/sl1673495/leetcode-javascript/issues/92) -[解数独-37](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/79) +[解数独-37](https://github.com/sl1673495/leetcode-javascript/issues/79) -[N皇后-51](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/78) +[N皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) -[单词搜索-79](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/77) +[单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) -[二进制手表-401](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/76) +[二进制手表-401](https://github.com/sl1673495/leetcode-javascript/issues/76) -[子集 II-90](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/75) +[子集 II-90](https://github.com/sl1673495/leetcode-javascript/issues/75) -[ 组合总和 III-216](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/74) +[ 组合总和 III-216](https://github.com/sl1673495/leetcode-javascript/issues/74) -[组合总和 II-40](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/73) +[组合总和 II-40](https://github.com/sl1673495/leetcode-javascript/issues/73) -[组合总和-39](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/72) +[组合总和-39](https://github.com/sl1673495/leetcode-javascript/issues/72) -[子集-78](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/71) +[子集-78](https://github.com/sl1673495/leetcode-javascript/issues/71) -[组合-77](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/70) +[组合-77](https://github.com/sl1673495/leetcode-javascript/issues/70) -[全排列 II-47](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/69) +[全排列 II-47](https://github.com/sl1673495/leetcode-javascript/issues/69) -[全排列-46](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/68) +[全排列-46](https://github.com/sl1673495/leetcode-javascript/issues/68) -[分割回文串-131](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/67) +[分割回文串-131](https://github.com/sl1673495/leetcode-javascript/issues/67) -[复原IP地址-93](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/66) +[复原IP地址-93](https://github.com/sl1673495/leetcode-javascript/issues/66) -[电话号码的字母组合-17](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/65) +[电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) ### 贪心算法 -[判断子序列-392](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/89) +[判断子序列-392](https://github.com/sl1673495/leetcode-javascript/issues/89) -[分发饼干-455](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/88) +[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) -[买卖股票的最佳时机 II-122](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/20) +[买卖股票的最佳时机 II-122](https://github.com/sl1673495/leetcode-javascript/issues/20) ### 例题详解 -[分发饼干-455](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/88) +[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) -[N皇后-51](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/78) +[N皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) -[单词搜索-79](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/77) +[单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) -[二进制手表-401](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/76) +[二进制手表-401](https://github.com/sl1673495/leetcode-javascript/issues/76) -[电话号码的字母组合-17](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/65) +[电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) -[二叉树的所有路径-257](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/59) +[二叉树的所有路径-257](https://github.com/sl1673495/leetcode-javascript/issues/59) -[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) +[路径总和-112](https://github.com/sl1673495/leetcode-javascript/issues/57) -[两两交换链表中的节点-24](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/51) +[两两交换链表中的节点-24](https://github.com/sl1673495/leetcode-javascript/issues/51) -[无重复字符的最长子串-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/42) +[无重复字符的最长子串-3](https://github.com/sl1673495/leetcode-javascript/issues/42) -[二分查找-704](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/23) +[二分查找-704](https://github.com/sl1673495/leetcode-javascript/issues/23) -[背包(01背包)](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/15) +[背包(01背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) -[盛水最多的容器-11](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/3) +[盛水最多的容器-11](https://github.com/sl1673495/leetcode-javascript/issues/3) -[斐波那契数-509](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/2) +[斐波那契数-509](https://github.com/sl1673495/leetcode-javascript/issues/2) ### DFS -[二叉树的最近公共祖先-236](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/64) +[二叉树的最近公共祖先-236](https://github.com/sl1673495/leetcode-javascript/issues/64) -[将有序数组转换为二叉搜索树](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/63) +[将有序数组转换为二叉搜索树](https://github.com/sl1673495/leetcode-javascript/issues/63) -[删除二叉搜索树中的节点-450](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/62) +[删除二叉搜索树中的节点-450](https://github.com/sl1673495/leetcode-javascript/issues/62) -[路径总和 III-437](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/61) +[路径总和 III-437](https://github.com/sl1673495/leetcode-javascript/issues/61) -[求根到叶子节点数字之和-129](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/60) +[求根到叶子节点数字之和-129](https://github.com/sl1673495/leetcode-javascript/issues/60) -[二叉树的所有路径-257](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/59) +[二叉树的所有路径-257](https://github.com/sl1673495/leetcode-javascript/issues/59) -[左叶子之和-404](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/58) +[左叶子之和-404](https://github.com/sl1673495/leetcode-javascript/issues/58) -[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) +[路径总和-112](https://github.com/sl1673495/leetcode-javascript/issues/57) -[平衡二叉树-110](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/56) +[平衡二叉树-110](https://github.com/sl1673495/leetcode-javascript/issues/56) -[对称二叉树-101](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/55) +[对称二叉树-101](https://github.com/sl1673495/leetcode-javascript/issues/55) -[二叉树的最小深度-111](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/54) +[二叉树的最小深度-111](https://github.com/sl1673495/leetcode-javascript/issues/54) -[二叉树的最大深度-104](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/53) +[二叉树的最大深度-104](https://github.com/sl1673495/leetcode-javascript/issues/53) -[二叉树的层序遍历](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/30) +[二叉树的层序遍历](https://github.com/sl1673495/leetcode-javascript/issues/30) -[路径总和 II-113](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/27) +[路径总和 II-113](https://github.com/sl1673495/leetcode-javascript/issues/27) -[相同的树-100](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/21) +[相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) -[打家劫舍 |||-337](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/11) +[打家劫舍 |||-337](https://github.com/sl1673495/leetcode-javascript/issues/11) -[被围绕的区域-130](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/6) +[被围绕的区域-130](https://github.com/sl1673495/leetcode-javascript/issues/6) -[岛屿的最大面积-695](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/5) +[岛屿的最大面积-695](https://github.com/sl1673495/leetcode-javascript/issues/5) ### 二叉树 -[二叉树的最近公共祖先-236](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/64) +[二叉树的最近公共祖先-236](https://github.com/sl1673495/leetcode-javascript/issues/64) -[将有序数组转换为二叉搜索树](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/63) +[将有序数组转换为二叉搜索树](https://github.com/sl1673495/leetcode-javascript/issues/63) -[删除二叉搜索树中的节点-450](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/62) +[删除二叉搜索树中的节点-450](https://github.com/sl1673495/leetcode-javascript/issues/62) -[路径总和 III-437](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/61) +[路径总和 III-437](https://github.com/sl1673495/leetcode-javascript/issues/61) -[求根到叶子节点数字之和-129](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/60) +[求根到叶子节点数字之和-129](https://github.com/sl1673495/leetcode-javascript/issues/60) -[二叉树的所有路径-257](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/59) +[二叉树的所有路径-257](https://github.com/sl1673495/leetcode-javascript/issues/59) -[左叶子之和-404](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/58) +[左叶子之和-404](https://github.com/sl1673495/leetcode-javascript/issues/58) -[路径总和-112](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/57) +[路径总和-112](https://github.com/sl1673495/leetcode-javascript/issues/57) -[平衡二叉树-110](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/56) +[平衡二叉树-110](https://github.com/sl1673495/leetcode-javascript/issues/56) -[对称二叉树-101](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/55) +[对称二叉树-101](https://github.com/sl1673495/leetcode-javascript/issues/55) -[二叉树的最小深度-111](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/54) +[二叉树的最小深度-111](https://github.com/sl1673495/leetcode-javascript/issues/54) -[二叉树的最大深度-104](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/53) +[二叉树的最大深度-104](https://github.com/sl1673495/leetcode-javascript/issues/53) -[二叉树的右视图-199](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/52) +[二叉树的右视图-199](https://github.com/sl1673495/leetcode-javascript/issues/52) -[二叉树的前序遍历-144](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/50) +[二叉树的前序遍历-144](https://github.com/sl1673495/leetcode-javascript/issues/50) -[二叉树的层序遍历](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/30) +[二叉树的层序遍历](https://github.com/sl1673495/leetcode-javascript/issues/30) -[路径总和 II-113](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/27) +[路径总和 II-113](https://github.com/sl1673495/leetcode-javascript/issues/27) -[相同的树-100](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/21) +[相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) ### BFS -[二叉树的最小深度-111](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/54) +[二叉树的最小深度-111](https://github.com/sl1673495/leetcode-javascript/issues/54) -[二叉树的最大深度-104](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/53) +[二叉树的最大深度-104](https://github.com/sl1673495/leetcode-javascript/issues/53) -[二叉树的右视图-199](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/52) +[二叉树的右视图-199](https://github.com/sl1673495/leetcode-javascript/issues/52) -[二叉树的层序遍历](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/30) +[二叉树的层序遍历](https://github.com/sl1673495/leetcode-javascript/issues/30) -[相同的树-100](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/21) +[相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) -[在每个树行中找最大值-515](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/4) +[在每个树行中找最大值-515](https://github.com/sl1673495/leetcode-javascript/issues/4) ### 栈和队列 -[二叉树的右视图-199](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/52) +[二叉树的右视图-199](https://github.com/sl1673495/leetcode-javascript/issues/52) -[二叉树的前序遍历-144](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/50) +[二叉树的前序遍历-144](https://github.com/sl1673495/leetcode-javascript/issues/50) -[简化路径-71](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/49) +[简化路径-71](https://github.com/sl1673495/leetcode-javascript/issues/49) -[有效的括号-20](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/48) +[有效的括号-20](https://github.com/sl1673495/leetcode-javascript/issues/48) -[逆波兰表达式求值-150](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/47) +[逆波兰表达式求值-150](https://github.com/sl1673495/leetcode-javascript/issues/47) ### 滑动窗口 -[滑动窗口的最大值-239](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/45) +[滑动窗口的最大值-239](https://github.com/sl1673495/leetcode-javascript/issues/45) -[找到字符串中所有字母异位词-438](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/44) +[找到字符串中所有字母异位词-438](https://github.com/sl1673495/leetcode-javascript/issues/44) -[最小覆盖子串-76](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/43) +[最小覆盖子串-76](https://github.com/sl1673495/leetcode-javascript/issues/43) -[无重复字符的最长子串-3](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/42) +[无重复字符的最长子串-3](https://github.com/sl1673495/leetcode-javascript/issues/42) -[长度最小的子数组-209](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/36) +[长度最小的子数组-209](https://github.com/sl1673495/leetcode-javascript/issues/36) ### 排序 -[快速排序](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/41) +[快速排序](https://github.com/sl1673495/leetcode-javascript/issues/41) -[颜色分类-75](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/28) +[颜色分类-75](https://github.com/sl1673495/leetcode-javascript/issues/28) ### 查找表 -[两个数组的交集 II-350](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/37) +[两个数组的交集 II-350](https://github.com/sl1673495/leetcode-javascript/issues/37) ### 数据结构 -[LRU 缓存机制-146](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/35) +[LRU 缓存机制-146](https://github.com/sl1673495/leetcode-javascript/issues/35) -[实现 Trie (前缀树)-208](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/14) +[实现 Trie (前缀树)-208](https://github.com/sl1673495/leetcode-javascript/issues/14) ### 二分查找 -[Pow(x, n)-50](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/25) - -[x 的平方根-69](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/24) - -[二分查找-704](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/23) - -### 复习 * 2 - -[打家劫舍 - 198](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/10) +[Pow(x, n)-50](https://github.com/sl1673495/leetcode-javascript/issues/25) -[整数拆分-343](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/7) +[x 的平方根-69](https://github.com/sl1673495/leetcode-javascript/issues/24) -[在每个树行中找最大值-515](https://api.github.com/repos/sl1673495/leetcode-javascript/issues/4) +[二分查找-704](https://github.com/sl1673495/leetcode-javascript/issues/23) ## Author From 25bebe355a1f750b330882a9ca1514ca205b2ef4 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Fri, 26 Jun 2020 19:11:23 +0800 Subject: [PATCH 11/37] =?UTF-8?q?feat:=20=E6=9C=80=E9=95=BF=E5=8D=95?= =?UTF-8?q?=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\235\242\350\257\225\351\242\230 17.15.js" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\215\225\350\257\215-\351\235\242\350\257\225\351\242\230 17.15.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\215\225\350\257\215-\351\235\242\350\257\225\351\242\230 17.15.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\215\225\350\257\215-\351\235\242\350\257\225\351\242\230 17.15.js" new file mode 100644 index 0000000..fe82f42 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\345\215\225\350\257\215-\351\235\242\350\257\225\351\242\230 17.15.js" @@ -0,0 +1,49 @@ +/** + * @param {string} s + * @param {string[]} wordDict + * @return {boolean} + */ +let wordBreak = function (s, wordDict) { + let n = s.length + if (!n) return true + + let wordSet = new Set(wordDict) + let dp = [] + dp[0] = true + + for (let i = 0; i <= n; i++) { + for (let j = i; j >= 0; j--) { + let word = s.slice(j, i) + if (wordSet.has(word) && dp[j]) { + dp[i] = true + break + } + } + } + + return !!dp[n] +} +/** + * @param {string[]} words + * @return {string} + */ +let longestWord = function (words) { + // 先长度降序 后字典序升序 排序 + words.sort((a, b) => { + let diff = b.length - a.length + if (diff !== 0) { + return diff + } else { + return a < b ? -1 : 1 + } + }) + words = Array.from(new Set(words)) + for (let i = 0; i < words.length; i++) { + let word = words[i] + let rest = words.slice(0, i).concat(words.slice(i + 1)) + if (wordBreak(word, rest)) { + return word + } + } + return "" +} \ No newline at end of file From 31d2d4ea14864cf33012a0f7cc45df0c388afba4 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Fri, 26 Jun 2020 19:12:15 +0800 Subject: [PATCH 12/37] =?UTF-8?q?feat:=20=E9=80=9A=E8=BF=87=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=AD=97=E6=AF=8D=E5=8C=B9=E9=85=8D=E5=88=B0=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E9=87=8C=E6=9C=80=E9=95=BF=E5=8D=95=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...51\225\277\345\215\225\350\257\215-524.js" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "\345\217\214\346\214\207\351\222\210/\351\200\232\350\277\207\345\210\240\351\231\244\345\255\227\346\257\215\345\214\271\351\205\215\345\210\260\345\255\227\345\205\270\351\207\214\346\234\200\351\225\277\345\215\225\350\257\215-524.js" diff --git "a/\345\217\214\346\214\207\351\222\210/\351\200\232\350\277\207\345\210\240\351\231\244\345\255\227\346\257\215\345\214\271\351\205\215\345\210\260\345\255\227\345\205\270\351\207\214\346\234\200\351\225\277\345\215\225\350\257\215-524.js" "b/\345\217\214\346\214\207\351\222\210/\351\200\232\350\277\207\345\210\240\351\231\244\345\255\227\346\257\215\345\214\271\351\205\215\345\210\260\345\255\227\345\205\270\351\207\214\346\234\200\351\225\277\345\215\225\350\257\215-524.js" new file mode 100644 index 0000000..1da6eb0 --- /dev/null +++ "b/\345\217\214\346\214\207\351\222\210/\351\200\232\350\277\207\345\210\240\351\231\244\345\255\227\346\257\215\345\214\271\351\205\215\345\210\260\345\255\227\345\205\270\351\207\214\346\234\200\351\225\277\345\215\225\350\257\215-524.js" @@ -0,0 +1,30 @@ +/** + * @param {string} s + * @param {string[]} d + * @return {string} + */ +let findLongestWord = function (s, d) { + let n = d.length + let points = Array(n).fill(-1) + + let find = "" + for (let i = 0; i < s.length; i++) { + let char = s[i] + for (let j = 0; j < n; j++) { + let targetChar = d[j][points[j] + 1] + if (char === targetChar) { + points[j]++ + let word = d[j] + let wl = d[j].length + if (points[j] === wl - 1) { + let fl = find.length + if (wl > fl || (wl === fl && word < find)) { + find = word + } + } + } + } + } + + return find +} \ No newline at end of file From 16fa5cc54456ce449382d60581f8f2779180a4d6 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Fri, 26 Jun 2020 19:43:04 +0800 Subject: [PATCH 13/37] =?UTF-8?q?feat:=20=E6=81=A2=E5=A4=8D=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\235\242\350\257\225\351\242\230 17.13.js" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" new file mode 100644 index 0000000..a76fea4 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" @@ -0,0 +1,19 @@ +/** + * @param {string[]} dictionary + * @param {string} sentence + * @return {number} + */ +let respace = function (dictionary, sentence) { + let n = sentence.length + let dp = [0] + for (let i = 1; i <= n; i++) { + let min = dp[i - 1] + 1 + for (let word of dictionary) { + if (sentence.substring(i - word.length, i) === word) { + min = Math.min(min, dp[i - word.length]) + } + } + dp[i] = min + } + return dp[n] +} \ No newline at end of file From f95e194e32100c1a2d0e22481fcecaeb6c3a16db Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 27 Jun 2020 01:52:29 +0800 Subject: [PATCH 14/37] =?UTF-8?q?feat:=20=E6=9C=80=E5=A4=A7=E6=AD=A3?= =?UTF-8?q?=E6=96=B9=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\235\242\350\257\225\351\242\230 17.13.js" | 2 +- ...46\255\243\346\226\271\345\275\242-221.js" | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\345\244\247\346\255\243\346\226\271\345\275\242-221.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" index a76fea4..676d151 100644 --- "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\201\242\345\244\215\347\251\272\346\240\274-\351\235\242\350\257\225\351\242\230 17.13.js" @@ -16,4 +16,4 @@ let respace = function (dictionary, sentence) { dp[i] = min } return dp[n] -} \ No newline at end of file +} diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\345\244\247\346\255\243\346\226\271\345\275\242-221.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\345\244\247\346\255\243\346\226\271\345\275\242-221.js" new file mode 100644 index 0000000..26c4815 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\345\244\247\346\255\243\346\226\271\345\275\242-221.js" @@ -0,0 +1,44 @@ +/** + * @param {character[][]} matrix + * @return {number} + */ +let maximalSquare = function (matrix) { + let maxY = matrix.length + if (!maxY) return 0 + let maxX = matrix[0].length + + let dp = [] + let max = 0 + + let dpBasic = (y, x) => { + if (matrix[y][x] === "1") { + max = 1 + dp[y][x] = 1 + } else { + dp[y][x] = 0 + } + } + for (let y = 0; y < maxY; y++) { + dp[y] = [] + dpBasic(y, 0) + } + for (let x = 1; x < maxX; x++) { + dpBasic(0, x) + } + + for (let y = 1; y < maxY; y++) { + for (let x = 1; x < maxX; x++) { + let val = matrix[y][x] + if (val === "0") { + dp[y][x] = 0 + } else { + let left = dp[y][x - 1] + let top = dp[y - 1][x] + let leftTop = dp[y - 1][x - 1] + dp[y][x] = Math.min(left, top, leftTop) + 1 + max = Math.max(max, dp[y][x]) + } + } + } + return max * max +} From 3698d2caf2189430020ddef5efdbff7b5df6cb50 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 27 Jun 2020 13:26:09 +0800 Subject: [PATCH 15/37] =?UTF-8?q?feat:=20=E8=B7=B3=E8=B7=83=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=20III?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7\203\346\270\270\346\210\217 III-1306.js" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 III-1306.js" diff --git "a/BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 III-1306.js" "b/BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 III-1306.js" new file mode 100644 index 0000000..73d910e --- /dev/null +++ "b/BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 III-1306.js" @@ -0,0 +1,27 @@ +/** + * @param {number[]} arr + * @param {number} start + * @return {boolean} + */ +let canReach = function (arr, start) { + let n = arr.length + let visited = [] + let queue = [start] + while (queue.length) { + let index = queue.pop() + let val = arr[index] + if (val === 0) { + return true + } + let left = index - val + let right = index + val + if (left >= 0 && !visited[left]) { + queue.push(left) + } + if (right < n && !visited[right]) { + queue.push(right) + } + visited[index] = true + } + return false +}; \ No newline at end of file From 1bf7e028caf19b8c7a5ce91c0686cbc91f6fae93 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 27 Jun 2020 14:27:55 +0800 Subject: [PATCH 16/37] =?UTF-8?q?feat:=20=E8=B7=B3=E8=B7=83=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=20IIII?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...67\203\346\270\270\346\210\217 IV-1345.js" | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 IV-1345.js" diff --git "a/BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 IV-1345.js" "b/BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 IV-1345.js" new file mode 100644 index 0000000..be115b2 --- /dev/null +++ "b/BFS\351\227\256\351\242\230/\350\267\263\350\267\203\346\270\270\346\210\217 IV-1345.js" @@ -0,0 +1,72 @@ +/** + * @param {number[]} arr + * @return {number} + */ +let minJumps = function (arr) { + let n = arr.length + if (n === 1) { + return 0 + } + + // 连续出现超过两次的数字就抛弃掉 + let newArr = [] + let sameCount = 0 + for (let i = 0; i < arr.length; i++) { + if (arr[i] === arr[i - 1]) { + sameCount += 1 + if (sameCount >= 2) { + continue + } else { + newArr.push(arr[i]) + } + } else { + newArr.push(arr[i]) + sameCount = 0 + } + } + arr = newArr + n = arr.length + // 遍历一遍 记录每个数字出现的下标位置 + let indexesMap = new Map() + for (let i = 0; i < n; i++) { + let val = arr[i] + let indexes = indexesMap.get(val) + if (!indexes) { + indexesMap.set(val, [i]) + } else { + indexes.push(i) + } + } + + let visited = [] + let count = 0 + let queue = [0] + while (queue.length) { + count++ + let len = queue.length + for (let i = 0; i < len; i++) { + let index = queue.shift() + // 找到了 由于bfs的特性 此时用的跳跃次数一定是最少的 + if (index === n - 1) { + return count - 1 + } + + // 没找到 继续把可以跳的几个位置都放入队列中 + let val = arr[index] + let left = index - 1 + let right = index + 1 + let sameIndexes = indexesMap.get(val) + + if (left >= 0 && !visited[left]) queue.push(left) + if (right < n && !visited[right]) queue.push(right) + for (let sameIndex of sameIndexes) { + if (sameIndex !== index && !visited[sameIndex]) { + queue.push(sameIndex) + } + } + + visited[index] = true + } + } + return n +} From 139997af166bff9fbf1d71795c8ae42ac1544162 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 27 Jun 2020 19:12:22 +0800 Subject: [PATCH 17/37] =?UTF-8?q?feat:=20=E9=BB=84=E9=87=91=E7=9F=BF?= =?UTF-8?q?=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\207\221\347\237\277\345\267\245-1219.js" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\273\204\351\207\221\347\237\277\345\267\245-1219.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\273\204\351\207\221\347\237\277\345\267\245-1219.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\273\204\351\207\221\347\237\277\345\267\245-1219.js" new file mode 100644 index 0000000..0d8d53c --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\273\204\351\207\221\347\237\277\345\267\245-1219.js" @@ -0,0 +1,69 @@ +/** + * @param {number[][]} grid + * @return {number} + */ +let getMaximumGold = function (grid) { + let maxY = grid.length + if (maxY === 0) { + return 0 + } + let maxX = grid[0].length + + let visited = [] + for (let y = 0; y < maxY; y++) { + visited[y] = [] + } + + let dirs = [ + [1, 0], + [-1, 0], + [0, -1], + [0, 1], + ] + + // 验证是否能走入这个格子 + // 1. 范围不能越界 + // 2. 本轮递归中未访问过 + // 3. 格子的值不能为 0 + let isValid = (y, x) => { + return ( + y >= 0 && + y < maxY && + x >= 0 && + x < maxX && + grid[y][x] !== 0 && + !visited[y][x] + ) + } + + let maxGold = 0 + let helper = (y, x, prevGold) => { + let val = grid[y][x] + let curGold = prevGold + val + if (curGold === 0) { + return + } + + for (let dir of dirs) { + let [diffY, diffX] = dir + let nextY = y + diffY + let nextX = x + diffX + if (isValid(nextY, nextX)) { + visited[y][x] = true + helper(nextY, nextX, curGold) + visited[y][x] = false + } else { + // 走到尽头或者不符合条件的了 + maxGold = Math.max(maxGold, curGold) + } + } + } + + for (let y = 0; y < maxY; y++) { + for (let x = 0; x < maxX; x++) { + helper(y, x, 0) + } + } + + return maxGold +} From cc700b8f12ff4e900b4442658e29f3ce758a0ced Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 27 Jun 2020 22:45:11 +0800 Subject: [PATCH 18/37] =?UTF-8?q?feat:=20=E6=B4=BB=E5=AD=97=E5=8D=B0?= =?UTF-8?q?=E5=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\255\227\345\215\260\345\210\267-1079.js" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\264\273\345\255\227\345\215\260\345\210\267-1079.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\264\273\345\255\227\345\215\260\345\210\267-1079.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\264\273\345\255\227\345\215\260\345\210\267-1079.js" new file mode 100644 index 0000000..40ff332 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\264\273\345\255\227\345\215\260\345\210\267-1079.js" @@ -0,0 +1,23 @@ +/** + * @param {string} tiles + * @return {number} + */ +let numTilePossibilities = function (tiles) { + let res = new Set() + + let helper = (prev, rest) => { + if (prev.length > 0) { + res.add(prev) + } + + for (let i = 0; i < rest.length; i++) { + let char = rest[i] + let cur = prev + char + helper(cur, rest.substring(0, i) + rest.substring(i + 1)) + } + } + + helper('', tiles) + + return res.size +}; \ No newline at end of file From 45e87ab6a3894dad8a5e3cb4d7f8791f1196bd7d Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 27 Jun 2020 23:00:50 +0800 Subject: [PATCH 19/37] =?UTF-8?q?feat:=20=E5=AD=97=E6=AF=8D=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E5=86=99=E5=85=A8=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...45\205\250\346\216\222\345\210\227-784.js" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227-784.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227-784.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227-784.js" new file mode 100644 index 0000000..91ba7b7 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\345\244\247\345\260\217\345\206\231\345\205\250\346\216\222\345\210\227-784.js" @@ -0,0 +1,34 @@ +/** + * @param {string} S + * @return {string[]} + */ +let letterCasePermutation = function (S) { + let res = [] + + let helper = (prev, rest) => { + if (prev.length === S.length) { + res.push(prev) + return + } + + let char = rest[0] + let word1 = prev + char + let nextRest = rest.substring(1) + + if (!isNaN(Number(char))) { + helper(word1, nextRest) + return + } else { + let upperChar = char.toUpperCase() + let char2 = upperChar === char ? char.toLowerCase() : upperChar + let word2 = prev + char2 + + helper(word1, nextRest) + helper(word2, nextRest) + } + } + + helper('', S) + + return res +}; \ No newline at end of file From 4f1565c231de33f607f881c7abe1a98fe3861370 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Mon, 29 Jun 2020 13:56:25 +0800 Subject: [PATCH 20/37] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9B=9E?= =?UTF-8?q?=E6=BA=AF=E5=92=8Cdp=E4=B8=A4=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...46\234\200\345\260\217\345\222\214-931.js" | 34 +++++++++ ...20\214\350\267\257\345\276\204 III-980.js" | 72 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\344\270\213\351\231\215\350\267\257\345\276\204\346\234\200\345\260\217\345\222\214-931.js" create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\344\270\215\345\220\214\350\267\257\345\276\204 III-980.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\344\270\213\351\231\215\350\267\257\345\276\204\346\234\200\345\260\217\345\222\214-931.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\344\270\213\351\231\215\350\267\257\345\276\204\346\234\200\345\260\217\345\222\214-931.js" new file mode 100644 index 0000000..30ef633 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\344\270\213\351\231\215\350\267\257\345\276\204\346\234\200\345\260\217\345\222\214-931.js" @@ -0,0 +1,34 @@ +/** + * @param {number[][]} A + * @return {number} + */ +let minFallingPathSum = function (A) { + let n = A.length + + let dp = [] + for (let i = 0; i < n; i++) { + dp[i] = [] + } + + for (let j = 0; j < n; j++) { + dp[n - 1][j] = A[n - 1][j] + } + + for (let i = n - 2; i >= 0; i--) { + for (let j = 0; j < n; j++) { + dp[i][j] = Infinity + let left = j - 1 + let right = j + 1 + let mid = j + let nextRowIndexes = [left, mid, right] + for (let nextRowIndex of nextRowIndexes) { + if (nextRowIndex >= 0 && nextRowIndex < n) { + dp[i][j] = Math.min(dp[i][j], A[i][j] + dp[i + 1][nextRowIndex]) + } + } + } + } + + // 第一行的最小值 可以确定整体的最小路径 + return Math.min(...dp[0]) +} diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\344\270\215\345\220\214\350\267\257\345\276\204 III-980.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\344\270\215\345\220\214\350\267\257\345\276\204 III-980.js" new file mode 100644 index 0000000..1213047 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\344\270\215\345\220\214\350\267\257\345\276\204 III-980.js" @@ -0,0 +1,72 @@ +/** + * @param {number[][]} grid + * @return {number} + */ +let uniquePathsIII = function (grid) { + let maxY = grid.length + if (!maxY) return 0 + let maxX = grid[0].length + + let validCellsCount = 0 + let entry + let visited = [] + for (let y = 0; y < maxY; y++) { + visited[y] = [] + for (let x = 0; x < maxX; x++) { + let val = grid[y][x] + if (val === 0) { + validCellsCount++ + } + if (val === 1) { + entry = [y, x] + } + } + } + + let isValid = (y, x) => { + return ( + y >= 0 && + y < maxY && + x >= 0 && + x < maxX && + !visited[y][x] && + grid[y][x] !== -1 + ) + } + + let dirs = [ + [-1, 0], + [1, 0], + [0, -1], + [0, 1], + ] + let res = 0 + + let dfs = (y, x, passCount) => { + let val = grid[y][x] + if (val === 2) { + if (passCount === validCellsCount) { + res++ + } + return + } else if (val === 0) { + passCount += 1 + } + + for (let [diffY, diffX] of dirs) { + let nextY = y + diffY + let nextX = x + diffX + if (isValid(nextY, nextX)) { + visited[nextY][nextX] = true + dfs(nextY, nextX, passCount) + visited[nextY][nextX] = false + } + } + } + + let [entryY, entryX] = entry + visited[entryY][entryX] = true + dfs(entryY, entryX, 0) + + return res +} From dba403a2d2695f0978ab12dafb0e35f7ba770f52 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Mon, 29 Jun 2020 14:22:29 +0800 Subject: [PATCH 21/37] =?UTF-8?q?feat:=20=E6=89=BE=E4=B8=8D=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\346\211\276\344\270\215\345\220\214-389.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "\344\275\215\350\277\220\347\256\227/\346\211\276\344\270\215\345\220\214-389.js" diff --git "a/\344\275\215\350\277\220\347\256\227/\346\211\276\344\270\215\345\220\214-389.js" "b/\344\275\215\350\277\220\347\256\227/\346\211\276\344\270\215\345\220\214-389.js" new file mode 100644 index 0000000..f21e453 --- /dev/null +++ "b/\344\275\215\350\277\220\347\256\227/\346\211\276\344\270\215\345\220\214-389.js" @@ -0,0 +1,15 @@ +/** + * @param {string} s + * @param {string} t + * @return {character} + */ +let findTheDifference = function (s, t) { + let rest = t.charCodeAt(t.length - 1) + for (let i = 0; i < s.length; i++) { + let charS = s[i] + let charT = t[i] + rest ^= charS.charCodeAt(0) + rest ^= charT.charCodeAt(0) + } + return String.fromCharCode(rest) +} From 1730cce4f4f5a4fe7b465f4b8dfdc03405b2543f Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Mon, 29 Jun 2020 22:38:12 +0800 Subject: [PATCH 22/37] =?UTF-8?q?feat:=20=E7=9F=A9=E9=98=B5=E7=BD=AE?= =?UTF-8?q?=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...45\255\220\346\225\260\347\273\204-560.js" | 23 ++++++++++++ ...351\230\265\347\275\256\351\233\266-73.js" | 37 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\222\214\344\270\272K\347\232\204\345\255\220\346\225\260\347\273\204-560.js" create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\347\237\251\351\230\265\347\275\256\351\233\266-73.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\222\214\344\270\272K\347\232\204\345\255\220\346\225\260\347\273\204-560.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\222\214\344\270\272K\347\232\204\345\255\220\346\225\260\347\273\204-560.js" new file mode 100644 index 0000000..25582b5 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\222\214\344\270\272K\347\232\204\345\255\220\346\225\260\347\273\204-560.js" @@ -0,0 +1,23 @@ +/** + * @param {number[]} nums + * @param {number} k + * @return {number} + */ +let subarraySum = function (nums, k) { + let n = nums.length + if (!n) { + return 0 + } + + let res = 0 + for (let i = 0; i < n; i++) { + let total = 0 + for (let j = i; j < n; j++) { + total += nums[j] + if (total === k) { + res += 1 + } + } + } + return res +}; \ No newline at end of file diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\347\237\251\351\230\265\347\275\256\351\233\266-73.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\347\237\251\351\230\265\347\275\256\351\233\266-73.js" new file mode 100644 index 0000000..fff9854 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\347\237\251\351\230\265\347\275\256\351\233\266-73.js" @@ -0,0 +1,37 @@ +/** + * @param {number[][]} matrix + * @return {void} Do not return anything, modify matrix in-place instead. + */ +let setZeroes = function (matrix) { + let maxY = matrix.length + if (!maxY) return + let maxX = matrix[0].length + + let handledRows = [] + let handledColumns = [] + + let zeros = [] + for (let y = 0; y < maxY; y++) { + for (let x = 0; x < maxX; x++) { + let val = matrix[y][x] + if (val === 0) { + zeros.push([y, x]) + } + } + } + + for (let [y, x] of zeros) { + if (!handledRows[x]) { + for (let i = 0; i < maxY; i++) { + matrix[i][x] = 0 + } + handledRows[x] = true + } + if (!handledColumns[y]) { + for (let i = 0; i < maxX; i++) { + matrix[y][i] = 0 + } + handledColumns[y] = true + } + } +}; \ No newline at end of file From 9781111a97f969709635092d2f056374cc66acda Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Tue, 30 Jun 2020 18:36:35 +0800 Subject: [PATCH 23/37] =?UTF-8?q?feat:=20=E8=9E=BA=E6=97=8B=E7=9F=A9?= =?UTF-8?q?=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...346\227\213\347\237\251\351\230\265-54.js" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\236\272\346\227\213\347\237\251\351\230\265-54.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\236\272\346\227\213\347\237\251\351\230\265-54.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\236\272\346\227\213\347\237\251\351\230\265-54.js" new file mode 100644 index 0000000..5b64a29 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\236\272\346\227\213\347\237\251\351\230\265-54.js" @@ -0,0 +1,56 @@ +/** + * @param {number[][]} matrix + * @return {number[]} + */ +let spiralOrder = function (matrix) { + let maxY = matrix.length + if (!maxY) return [] + let maxX = matrix[0].length + + // 记录一个 visited 数组 + // 按照 右 -> 下 -> 左 -> 上 的方向不断前进 + // 直到遇到边界或者已经访问过的元素 则切换成下一个方向 + let dirs = [ + [0, 1], // 右 + [1, 0], // 下 + [0, -1], // 左 + [-1, 0], // 上 + ] + + let currentDirIndex = 0 + + let visited = [] + for (let y = 0; y < maxY; y++) { + visited[y] = [] + } + let isValid = (y, x) => { + return y >= 0 && y < maxY && x >= 0 && x < maxX && !visited[y][x] + } + + let targetLength = maxY * maxX + let res = [] + + let helper = (y, x) => { + let val = matrix[y][x] + res.push(val) + + if (res.length === targetLength) { + return res + } + + visited[y][x] = true + let [diffY, diffX] = dirs[currentDirIndex % 4] + let nextY = y + diffY + let nextX = x + diffX + if (!isValid(nextY, nextX)) { + [diffY, diffX] = dirs[++currentDirIndex % 4] + nextY = y + diffY + nextX = x + diffX + } + helper(nextY, nextX) + } + + helper(0, 0) + + return res +}; \ No newline at end of file From e0a5640a04f9f71b3fba5799b767598582ee9393 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Tue, 30 Jun 2020 18:56:38 +0800 Subject: [PATCH 24/37] =?UTF-8?q?feat:=20=E8=9E=BA=E6=97=8B=E7=9F=A9?= =?UTF-8?q?=E9=98=B5=20II?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...345\275\222\347\237\251\351\230\265-59.js" | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\200\222\345\275\222\347\237\251\351\230\265-59.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\200\222\345\275\222\347\237\251\351\230\265-59.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\200\222\345\275\222\347\237\251\351\230\265-59.js" new file mode 100644 index 0000000..0be2940 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\200\222\345\275\222\347\237\251\351\230\265-59.js" @@ -0,0 +1,54 @@ +/** + * @param {number} n + * @return {number[][]} + */ +let generateMatrix = function (n) { + // 记录一个 visited 数组 + // 按照 右 -> 下 -> 左 -> 上 的方向不断前进 + // 直到遇到边界或者已经访问过的元素 则切换成下一个方向 + let dirs = [ + [0, 1], // 右 + [1, 0], // 下 + [0, -1], // 左 + [-1, 0], // 上 + ] + + let currentDirIndex = 0 + + let visited = [] + for (let y = 0; y < n; y++) { + visited[y] = [] + } + let isValid = (y, x) => { + return y >= 0 && y < n && x >= 0 && x < n && !visited[y][x] + } + + let targetLength = n * n + let res = [] + for (let y = 0; y < n; y++) { + res[y] = [] + } + + let helper = (y, x, num) => { + res[y][x] = num + + if (num === targetLength) { + return res + } + + visited[y][x] = true + let [diffY, diffX] = dirs[currentDirIndex % 4] + let nextY = y + diffY + let nextX = x + diffX + if (!isValid(nextY, nextX)) { + ;[diffY, diffX] = dirs[++currentDirIndex % 4] + nextY = y + diffY + nextX = x + diffX + } + helper(nextY, nextX, num + 1) + } + + helper(0, 0, 1) + + return res +} From 5ddd7703d145bb811388599d6b470d348f82de91 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Wed, 1 Jul 2020 00:34:36 +0800 Subject: [PATCH 25/37] =?UTF-8?q?feat:=20=E6=9C=80=E9=95=BF=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=AD=90=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...45\255\220\346\225\260\347\273\204-718.js" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204-718.js" diff --git "a/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204-718.js" "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204-718.js" new file mode 100644 index 0000000..a4dfc61 --- /dev/null +++ "b/\345\212\250\346\200\201\350\247\204\345\210\222/\346\234\200\351\225\277\351\207\215\345\244\215\345\255\220\346\225\260\347\273\204-718.js" @@ -0,0 +1,33 @@ +/** + * @param {number[]} A + * @param {number[]} B + * @return {number} + */ +let findLength = function (A, B) { + let dp = [] + let al = A.length + let bl = B.length + + for (let i = 0; i <= al; i++) { + dp[i] = [] + for (let j = 0; j <= bl; j++) { + dp[i][j] = 0 + } + } + + let max = 0 + for (let i = al - 1; i >= 0; i--) { + for (let j = bl - 1; j >= 0; j--) { + let a = A[i] + let b = B[j] + + if (a === b) { + dp[i][j] = dp[i + 1][j + 1] + 1 + max = Math.max(max, dp[i][j]) + } else { + dp[i][j] = 0 + } + } + } + return max +} From 8e35d3b4581200dd36f008973a02d268a3684f10 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Wed, 1 Jul 2020 02:30:25 +0800 Subject: [PATCH 26/37] =?UTF-8?q?feat:=20=E6=9C=80=E6=8E=A5=E8=BF=91?= =?UTF-8?q?=E7=9A=84=E4=B8=89=E6=95=B0=E4=B9=8B=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...346\225\260\344\271\213\345\222\214-16.js" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "\345\217\214\346\214\207\351\222\210/\346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214-16.js" diff --git "a/\345\217\214\346\214\207\351\222\210/\346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214-16.js" "b/\345\217\214\346\214\207\351\222\210/\346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214-16.js" new file mode 100644 index 0000000..70d7631 --- /dev/null +++ "b/\345\217\214\346\214\207\351\222\210/\346\234\200\346\216\245\350\277\221\347\232\204\344\270\211\346\225\260\344\271\213\345\222\214-16.js" @@ -0,0 +1,49 @@ +/** + * @param {number[]} nums + * @param {number} target + * @return {number} + */ +let threeSumClosest = function (nums, target) { + let n = nums.length + if (n === 3) { + return getSum(nums) + } + // 先升序排序 此为解题的前置条件 + nums.sort((a, b) => a - b) + + let min = Infinity // 和 target 的最小差 + let res + + // 从左往右依次尝试定一个基础指针 右边至少再保留两位 否则无法凑成3个 + for (let i = 0; i <= nums.length - 3; i++) { + let basic = nums[i] + let left = i + 1 // 左指针先从 i 右侧的第一位开始尝试 + let right = n - 1 // 右指针先从数组最后一项开始尝试 + + while (left < right) { + let sum = basic + nums[left] + nums[right] // 三数求和 + // 更新最小差 + let diff = Math.abs(sum - target) + if (diff < min) { + min = diff + res = sum + } + if (sum < target) { + // 求出的和如果小于目标值的话 可以尝试把左指针右移 扩大值 + left++ + } else if (sum > target) { + // 反之则右指针左移 + right-- + } else { + // 相等的话 差就为0 一定是答案 + return sum + } + } + } + + return res +} + +function getSum(nums) { + return nums.reduce((total, cur) => total + cur, 0) +} From 17a4ea3ea7d526126eda6e8cd8864ca42a903484 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Thu, 2 Jul 2020 21:21:12 +0800 Subject: [PATCH 27/37] =?UTF-8?q?feat:=20=E6=9C=89=E5=BA=8F=E7=9F=A9?= =?UTF-8?q?=E9=98=B5=E4=B8=AD=E7=AC=ACK=E5=B0=8F=E7=9A=84=E5=85=83?= =?UTF-8?q?=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...47\232\204\345\205\203\347\264\240-378.js" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "\346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254K\345\260\217\347\232\204\345\205\203\347\264\240-378.js" diff --git "a/\346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254K\345\260\217\347\232\204\345\205\203\347\264\240-378.js" "b/\346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254K\345\260\217\347\232\204\345\205\203\347\264\240-378.js" new file mode 100644 index 0000000..6ce08fc --- /dev/null +++ "b/\346\234\211\345\272\217\347\237\251\351\230\265\344\270\255\347\254\254K\345\260\217\347\232\204\345\205\203\347\264\240-378.js" @@ -0,0 +1,31 @@ +/** + * @param {number[][]} matrix + * @param {number} k + * @return {number} + */ +let kthSmallest = function (matrix, k) { + let maxY = matrix.length + let sorted = [] + let points = [] + for (let i = 0; i < maxY; i++) { + points[i] = 0 + } + + while (sorted.length < k) { + let min = Infinity + let minY + for (let y = 0; y < maxY; y++) { + let point = points[y] + let num = matrix[y][point] + if (num < min) { + min = num + minY = y + } + } + sorted.push(min) + // 选中最小项的x指针右移 + points[minY]++ + } + + return sorted[sorted.length - 1] +}; \ No newline at end of file From 6064152a745b263cc0b68a799e29dd8ff42be72b Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 4 Jul 2020 12:40:30 +0800 Subject: [PATCH 28/37] =?UTF-8?q?feat:=20=E5=AD=97=E6=AF=8D=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E7=BB=84=E5=90=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7\273\204\345\220\210\345\231\250-1286.js" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\350\277\255\344\273\243\347\273\204\345\220\210\345\231\250-1286.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\350\277\255\344\273\243\347\273\204\345\220\210\345\231\250-1286.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\350\277\255\344\273\243\347\273\204\345\220\210\345\231\250-1286.js" new file mode 100644 index 0000000..709bae1 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\345\255\227\346\257\215\350\277\255\344\273\243\347\273\204\345\220\210\345\231\250-1286.js" @@ -0,0 +1,52 @@ +/** + * @param {string} characters + * @param {number} combinationLength + */ +let CombinationIterator = function (characters, combinationLength) { + let cl = characters.length + let res = [] + let helper = (start, prev) => { + let pl = prev.length + for (let i = start; i < cl; i++) { + let rest = cl - i + let diff = combinationLength - pl + if (diff > rest) { + return + } + let next = prev + characters[i] + if (next.length == combinationLength) { + res.push(next) + } else { + helper(i + 1, next) + } + } + } + helper(0, "") + this.res = res.sort((a, b) => (a > b ? 1 : -1)) + this.point = 0 +} + +/** + * @return {string} + */ +CombinationIterator.prototype.next = function () { + if (!this.hasNext()) { + return undefined + } + let val = this.res[this.point++] + return val +} + +/** + * @return {boolean} + */ +CombinationIterator.prototype.hasNext = function () { + return this.point !== this.res.length +} + +/** + * Your CombinationIterator object will be instantiated and called as such: + * var obj = new CombinationIterator(characters, combinationLength) + * var param_1 = obj.next() + * var param_2 = obj.hasNext() + */ From 3998c84f22cea30b10a49751dbeff6245b43d48c Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sat, 4 Jul 2020 14:22:18 +0800 Subject: [PATCH 29/37] =?UTF-8?q?feat:=20=E9=A1=BA=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\241\272\346\254\241\346\225\260-1291.js" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\241\272\346\254\241\346\225\260-1291.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\241\272\346\254\241\346\225\260-1291.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\241\272\346\254\241\346\225\260-1291.js" new file mode 100644 index 0000000..13f8a5c --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\351\241\272\346\254\241\346\225\260-1291.js" @@ -0,0 +1,30 @@ +/** + * @param {number} low + * @param {number} high + * @return {number[]} + */ +let sequentialDigits = function (low, high) { + let lowLen = low.toString().length + let highLen = high.toString().length + let lens = [] + for (let i = lowLen; i <= highLen; i++) { + lens.push(i) + } + + let res = [] + for (let i = 0; i < lens.length; i++) { + let len = lens[i] + for (let start = 1; start <= 10 - len; start++) { + let num = start + + for (let n = start + 1; n < start + len; n++) { + num = 10 * num + n + } + if (num <= high && num >= low) { + res.push(num) + } + } + } + + return res +} \ No newline at end of file From 852f31f67ffe3fa21784d3b93df8e9b73c1cac49 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Sun, 5 Jul 2020 02:13:23 +0800 Subject: [PATCH 30/37] docs: format --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a61690a..dfd2737 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ 思路会记录在本仓库的 Issues 中,按照 label 进行分类。比如想查看 「DFS」 分类下的问题,那么选择标签进行筛选即可。 ## 目录 + ### 链表 [移除链表元素-203](https://github.com/sl1673495/leetcode-javascript/issues/97) @@ -24,11 +25,11 @@ [两两交换链表中的节点-24](https://github.com/sl1673495/leetcode-javascript/issues/51) -[删除链表的倒数第N个节点-19](https://github.com/sl1673495/leetcode-javascript/issues/46) +[删除链表的倒数第 N 个节点-19](https://github.com/sl1673495/leetcode-javascript/issues/46) -[删除链表的节点-面试题18](https://github.com/sl1673495/leetcode-javascript/issues/40) +[删除链表的节点-面试题 18](https://github.com/sl1673495/leetcode-javascript/issues/40) -[反转链表II-92](https://github.com/sl1673495/leetcode-javascript/issues/39) +[反转链表 II-92](https://github.com/sl1673495/leetcode-javascript/issues/39) [反转链表 206](https://github.com/sl1673495/leetcode-javascript/issues/38) @@ -90,9 +91,9 @@ [最大子序和-53](https://github.com/sl1673495/leetcode-javascript/issues/17) -[分割等和子集(01背包的变种)-416](https://github.com/sl1673495/leetcode-javascript/issues/16) +[分割等和子集(01 背包的变种)-416](https://github.com/sl1673495/leetcode-javascript/issues/16) -[背包(01背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) +[背包(01 背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) [使用最小花费爬楼梯-746](https://github.com/sl1673495/leetcode-javascript/issues/13) @@ -112,7 +113,7 @@ [解数独-37](https://github.com/sl1673495/leetcode-javascript/issues/79) -[N皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) +[N 皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) [单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) @@ -136,7 +137,7 @@ [分割回文串-131](https://github.com/sl1673495/leetcode-javascript/issues/67) -[复原IP地址-93](https://github.com/sl1673495/leetcode-javascript/issues/66) +[复原 IP 地址-93](https://github.com/sl1673495/leetcode-javascript/issues/66) [电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) @@ -152,7 +153,7 @@ [分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) -[N皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) +[N 皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) [单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) @@ -170,7 +171,7 @@ [二分查找-704](https://github.com/sl1673495/leetcode-javascript/issues/23) -[背包(01背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) +[背包(01 背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) [盛水最多的容器-11](https://github.com/sl1673495/leetcode-javascript/issues/3) From c674be0d0e465fa31a87cf01bb1c3b5e1ef7a80c Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Tue, 7 Jul 2020 16:45:37 +0800 Subject: [PATCH 31/37] =?UTF-8?q?feat:=20=E6=8B=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\235\242\350\257\225\351\242\230 08.09.js" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\213\254\345\217\267-\351\235\242\350\257\225\351\242\230 08.09.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\213\254\345\217\267-\351\235\242\350\257\225\351\242\230 08.09.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\213\254\345\217\267-\351\235\242\350\257\225\351\242\230 08.09.js" new file mode 100644 index 0000000..604f5c4 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\346\213\254\345\217\267-\351\235\242\350\257\225\351\242\230 08.09.js" @@ -0,0 +1,23 @@ +/** + * @param {number} n + * @return {string[]} + */ +let generateParenthesis = function (n) { + let res = [] + + let helper = (left, right, prev) => { + if (left < 0 || right < 0 || right < left) { + return + } + if (left === 0 && right === 0) { + res.push(prev) + return + } + + helper(left - 1, right, prev + "(") + helper(left, right - 1, prev + ")") + } + + helper(n, n, '') + return res +}; \ No newline at end of file From a5adb8ef868b4ca83b66c0ac03814e84426d6b07 Mon Sep 17 00:00:00 2001 From: sl1673495 <949589855@qq.com> Date: Wed, 8 Jul 2020 23:51:45 +0800 Subject: [PATCH 32/37] =?UTF-8?q?feat:=20=E8=B7=B3=E6=B0=B4=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\235\242\350\257\225\351\242\230 16.11.js" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\267\263\346\260\264\346\235\277-\351\235\242\350\257\225\351\242\230 16.11.js" diff --git "a/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\267\263\346\260\264\346\235\277-\351\235\242\350\257\225\351\242\230 16.11.js" "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\267\263\346\260\264\346\235\277-\351\235\242\350\257\225\351\242\230 16.11.js" new file mode 100644 index 0000000..fb26019 --- /dev/null +++ "b/\351\200\222\345\275\222\344\270\216\345\233\236\346\272\257/\350\267\263\346\260\264\346\235\277-\351\235\242\350\257\225\351\242\230 16.11.js" @@ -0,0 +1,23 @@ +/** + * @param {number} shorter + * @param {number} longer + * @param {number} k + * @return {number[]} + */ +let divingBoard = function (shorter, longer, k) { + if (k === 0) { + return [] + } + if (shorter === longer) { + return [k * shorter] + } + + let res = [] + for (let i = 0; i <= k; i++) { + let longCount = i + let shortCount = k - i + res.push(shortCount * shorter + longCount * longer) + } + + return res +}; \ No newline at end of file From d1ad49174b0e7e8be76f7d8269740bc602a1bd06 Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Sat, 11 Jul 2020 14:00:39 +0800 Subject: [PATCH 33/37] Update README.md --- README.md | 217 +++++++++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 99 deletions(-) diff --git a/README.md b/README.md index dfd2737..78e30a6 100644 --- a/README.md +++ b/README.md @@ -17,44 +17,101 @@ ## 目录 -### 链表 -[移除链表元素-203](https://github.com/sl1673495/leetcode-javascript/issues/97) +### 例题详解 -[两数相加-3](https://github.com/sl1673495/leetcode-javascript/issues/94) +[最接近的三数之和-16](https://github.com/sl1673495/leetcode-javascript/issues/115) + +[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) + +[N皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) + +[单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) + +[二进制手表-401](https://github.com/sl1673495/leetcode-javascript/issues/76) + +[电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) + +[二叉树的所有路径-257](https://github.com/sl1673495/leetcode-javascript/issues/59) + +[路径总和-112](https://github.com/sl1673495/leetcode-javascript/issues/57) [两两交换链表中的节点-24](https://github.com/sl1673495/leetcode-javascript/issues/51) -[删除链表的倒数第 N 个节点-19](https://github.com/sl1673495/leetcode-javascript/issues/46) +[有效的括号-20](https://github.com/sl1673495/leetcode-javascript/issues/48) + +[无重复字符的最长子串-3](https://github.com/sl1673495/leetcode-javascript/issues/42) -[删除链表的节点-面试题 18](https://github.com/sl1673495/leetcode-javascript/issues/40) +[二分查找-704](https://github.com/sl1673495/leetcode-javascript/issues/23) -[反转链表 II-92](https://github.com/sl1673495/leetcode-javascript/issues/39) +### 递归与回溯 -[反转链表 206](https://github.com/sl1673495/leetcode-javascript/issues/38) +[跳水板-面试题 16.11 ](https://github.com/sl1673495/leetcode-javascript/issues/118) -### 双指针 +[顺次数-1291](https://github.com/sl1673495/leetcode-javascript/issues/116) -[搜索二维矩阵 II-240](https://github.com/sl1673495/leetcode-javascript/issues/96) +[螺旋矩阵 II-59](https://github.com/sl1673495/leetcode-javascript/issues/113) -[判断子序列-392](https://github.com/sl1673495/leetcode-javascript/issues/89) +[螺旋矩阵-54](https://github.com/sl1673495/leetcode-javascript/issues/112) -[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) +[矩阵置零-73](https://github.com/sl1673495/leetcode-javascript/issues/111) -[验证回文串-125](https://github.com/sl1673495/leetcode-javascript/issues/33) +[不同路径 III-980](https://github.com/sl1673495/leetcode-javascript/issues/107) -[两数之和 II - 输入有序数组-167](https://github.com/sl1673495/leetcode-javascript/issues/32) +[字母大小写全排列-784](https://github.com/sl1673495/leetcode-javascript/issues/106) -[合并两个有序数组-88](https://github.com/sl1673495/leetcode-javascript/issues/29) +[黄金矿工-1219](https://github.com/sl1673495/leetcode-javascript/issues/105) -[移动零-283](https://github.com/sl1673495/leetcode-javascript/issues/26) +[有重复字符串的排列组合-面试题 08.08](https://github.com/sl1673495/leetcode-javascript/issues/104) + +[单词搜索 II-212](https://github.com/sl1673495/leetcode-javascript/issues/92) + +[解数独-37](https://github.com/sl1673495/leetcode-javascript/issues/79) + +[N皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) + +[单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) -[删除排序数组中的重复项-26](https://github.com/sl1673495/leetcode-javascript/issues/8) +[二进制手表-401](https://github.com/sl1673495/leetcode-javascript/issues/76) + +[子集 II-90](https://github.com/sl1673495/leetcode-javascript/issues/75) + +[ 组合总和 III-216](https://github.com/sl1673495/leetcode-javascript/issues/74) + +[组合总和 II-40](https://github.com/sl1673495/leetcode-javascript/issues/73) + +[组合总和-39](https://github.com/sl1673495/leetcode-javascript/issues/72) + +[子集-78](https://github.com/sl1673495/leetcode-javascript/issues/71) + +[组合-77](https://github.com/sl1673495/leetcode-javascript/issues/70) + +[全排列 II-47](https://github.com/sl1673495/leetcode-javascript/issues/69) + +[全排列-46](https://github.com/sl1673495/leetcode-javascript/issues/68) + +[分割回文串-131](https://github.com/sl1673495/leetcode-javascript/issues/67) -[盛水最多的容器-11](https://github.com/sl1673495/leetcode-javascript/issues/3) +[复原IP地址-93](https://github.com/sl1673495/leetcode-javascript/issues/66) + +[电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) + +[括号生成-22](https://github.com/sl1673495/leetcode-javascript/issues/31) ### 动态规划 +[最长的斐波那契子序列的长度-873](https://github.com/sl1673495/leetcode-javascript/issues/117) + +[最长重复子数组-718](https://github.com/sl1673495/leetcode-javascript/issues/114) + +[下降路径最小和-931](https://github.com/sl1673495/leetcode-javascript/issues/108) + +[最大正方形-221](https://github.com/sl1673495/leetcode-javascript/issues/101) + +[恢复空格-面试题 17.13](https://github.com/sl1673495/leetcode-javascript/issues/100) + +[最长单词-面试题 17.15](https://github.com/sl1673495/leetcode-javascript/issues/99) + [单词拆分 II-140](https://github.com/sl1673495/leetcode-javascript/issues/95) [单词拆分-139](https://github.com/sl1673495/leetcode-javascript/issues/93) @@ -87,95 +144,89 @@ [买卖股票的最佳时机-121](https://github.com/sl1673495/leetcode-javascript/issues/19) -[乘积最大子数组-152](https://github.com/sl1673495/leetcode-javascript/issues/18) - -[最大子序和-53](https://github.com/sl1673495/leetcode-javascript/issues/17) - -[分割等和子集(01 背包的变种)-416](https://github.com/sl1673495/leetcode-javascript/issues/16) - -[背包(01 背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) +### 双指针 -[使用最小花费爬楼梯-746](https://github.com/sl1673495/leetcode-javascript/issues/13) +[最接近的三数之和-16](https://github.com/sl1673495/leetcode-javascript/issues/115) -[零钱兑换 II-518](https://github.com/sl1673495/leetcode-javascript/issues/12) +[通过删除字母匹配到字典里最长单词-524](https://github.com/sl1673495/leetcode-javascript/issues/98) -[打家劫舍 - 198](https://github.com/sl1673495/leetcode-javascript/issues/10) +[搜索二维矩阵 II-240](https://github.com/sl1673495/leetcode-javascript/issues/96) -[完全平方数-279](https://github.com/sl1673495/leetcode-javascript/issues/9) +[判断子序列-392](https://github.com/sl1673495/leetcode-javascript/issues/89) -[整数拆分-343](https://github.com/sl1673495/leetcode-javascript/issues/7) +[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) -[斐波那契数-509](https://github.com/sl1673495/leetcode-javascript/issues/2) +[验证回文串-125](https://github.com/sl1673495/leetcode-javascript/issues/33) -### 递归与回溯 +[两数之和 II - 输入有序数组-167](https://github.com/sl1673495/leetcode-javascript/issues/32) -[单词搜索 II-212](https://github.com/sl1673495/leetcode-javascript/issues/92) +[合并两个有序数组-88](https://github.com/sl1673495/leetcode-javascript/issues/29) -[解数独-37](https://github.com/sl1673495/leetcode-javascript/issues/79) +[移动零-283](https://github.com/sl1673495/leetcode-javascript/issues/26) -[N 皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) +### 前缀和 -[单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) +[和为K的子数组-560](https://github.com/sl1673495/leetcode-javascript/issues/110) -[二进制手表-401](https://github.com/sl1673495/leetcode-javascript/issues/76) +### 位运算 -[子集 II-90](https://github.com/sl1673495/leetcode-javascript/issues/75) +[找不同-389](https://github.com/sl1673495/leetcode-javascript/issues/109) -[ 组合总和 III-216](https://github.com/sl1673495/leetcode-javascript/issues/74) +### 查找表 -[组合总和 II-40](https://github.com/sl1673495/leetcode-javascript/issues/73) +[找不同-389](https://github.com/sl1673495/leetcode-javascript/issues/109) -[组合总和-39](https://github.com/sl1673495/leetcode-javascript/issues/72) +[两个数组的交集 II-350](https://github.com/sl1673495/leetcode-javascript/issues/37) -[子集-78](https://github.com/sl1673495/leetcode-javascript/issues/71) +### BFS -[组合-77](https://github.com/sl1673495/leetcode-javascript/issues/70) +[跳跃游戏 IV-1345](https://github.com/sl1673495/leetcode-javascript/issues/103) -[全排列 II-47](https://github.com/sl1673495/leetcode-javascript/issues/69) +[跳跃游戏 III-1306](https://github.com/sl1673495/leetcode-javascript/issues/102) -[全排列-46](https://github.com/sl1673495/leetcode-javascript/issues/68) +[二叉树的最小深度-111](https://github.com/sl1673495/leetcode-javascript/issues/54) -[分割回文串-131](https://github.com/sl1673495/leetcode-javascript/issues/67) +[二叉树的最大深度-104](https://github.com/sl1673495/leetcode-javascript/issues/53) -[复原 IP 地址-93](https://github.com/sl1673495/leetcode-javascript/issues/66) +[二叉树的右视图-199](https://github.com/sl1673495/leetcode-javascript/issues/52) -[电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) +[二叉树的层序遍历-102](https://github.com/sl1673495/leetcode-javascript/issues/30) -### 贪心算法 +[相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) -[判断子序列-392](https://github.com/sl1673495/leetcode-javascript/issues/89) +### 排序 -[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) +[最长单词-面试题 17.15](https://github.com/sl1673495/leetcode-javascript/issues/99) -[买卖股票的最佳时机 II-122](https://github.com/sl1673495/leetcode-javascript/issues/20) +[通过删除字母匹配到字典里最长单词-524](https://github.com/sl1673495/leetcode-javascript/issues/98) -### 例题详解 +[快速排序](https://github.com/sl1673495/leetcode-javascript/issues/41) -[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) +[颜色分类-75](https://github.com/sl1673495/leetcode-javascript/issues/28) -[N 皇后-51](https://github.com/sl1673495/leetcode-javascript/issues/78) +### 链表 -[单词搜索-79](https://github.com/sl1673495/leetcode-javascript/issues/77) +[移除链表元素-203](https://github.com/sl1673495/leetcode-javascript/issues/97) -[二进制手表-401](https://github.com/sl1673495/leetcode-javascript/issues/76) +[两数相加-3](https://github.com/sl1673495/leetcode-javascript/issues/94) -[电话号码的字母组合-17](https://github.com/sl1673495/leetcode-javascript/issues/65) +[两两交换链表中的节点-24](https://github.com/sl1673495/leetcode-javascript/issues/51) -[二叉树的所有路径-257](https://github.com/sl1673495/leetcode-javascript/issues/59) +[删除链表的倒数第N个节点-19](https://github.com/sl1673495/leetcode-javascript/issues/46) -[路径总和-112](https://github.com/sl1673495/leetcode-javascript/issues/57) +[删除链表的节点-面试题18](https://github.com/sl1673495/leetcode-javascript/issues/40) -[两两交换链表中的节点-24](https://github.com/sl1673495/leetcode-javascript/issues/51) +[反转链表II-92](https://github.com/sl1673495/leetcode-javascript/issues/39) -[无重复字符的最长子串-3](https://github.com/sl1673495/leetcode-javascript/issues/42) +[反转链表 206](https://github.com/sl1673495/leetcode-javascript/issues/38) -[二分查找-704](https://github.com/sl1673495/leetcode-javascript/issues/23) +### 贪心算法 -[背包(01 背包)](https://github.com/sl1673495/leetcode-javascript/issues/15) +[判断子序列-392](https://github.com/sl1673495/leetcode-javascript/issues/89) -[盛水最多的容器-11](https://github.com/sl1673495/leetcode-javascript/issues/3) +[分发饼干-455](https://github.com/sl1673495/leetcode-javascript/issues/88) -[斐波那契数-509](https://github.com/sl1673495/leetcode-javascript/issues/2) +[买卖股票的最佳时机 II-122](https://github.com/sl1673495/leetcode-javascript/issues/20) ### DFS @@ -203,18 +254,12 @@ [二叉树的最大深度-104](https://github.com/sl1673495/leetcode-javascript/issues/53) -[二叉树的层序遍历](https://github.com/sl1673495/leetcode-javascript/issues/30) +[二叉树的层序遍历-102](https://github.com/sl1673495/leetcode-javascript/issues/30) [路径总和 II-113](https://github.com/sl1673495/leetcode-javascript/issues/27) [相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) -[打家劫舍 |||-337](https://github.com/sl1673495/leetcode-javascript/issues/11) - -[被围绕的区域-130](https://github.com/sl1673495/leetcode-javascript/issues/6) - -[岛屿的最大面积-695](https://github.com/sl1673495/leetcode-javascript/issues/5) - ### 二叉树 [二叉树的最近公共祖先-236](https://github.com/sl1673495/leetcode-javascript/issues/64) @@ -245,26 +290,12 @@ [二叉树的前序遍历-144](https://github.com/sl1673495/leetcode-javascript/issues/50) -[二叉树的层序遍历](https://github.com/sl1673495/leetcode-javascript/issues/30) +[二叉树的层序遍历-102](https://github.com/sl1673495/leetcode-javascript/issues/30) [路径总和 II-113](https://github.com/sl1673495/leetcode-javascript/issues/27) [相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) -### BFS - -[二叉树的最小深度-111](https://github.com/sl1673495/leetcode-javascript/issues/54) - -[二叉树的最大深度-104](https://github.com/sl1673495/leetcode-javascript/issues/53) - -[二叉树的右视图-199](https://github.com/sl1673495/leetcode-javascript/issues/52) - -[二叉树的层序遍历](https://github.com/sl1673495/leetcode-javascript/issues/30) - -[相同的树-100](https://github.com/sl1673495/leetcode-javascript/issues/21) - -[在每个树行中找最大值-515](https://github.com/sl1673495/leetcode-javascript/issues/4) - ### 栈和队列 [二叉树的右视图-199](https://github.com/sl1673495/leetcode-javascript/issues/52) @@ -289,22 +320,10 @@ [长度最小的子数组-209](https://github.com/sl1673495/leetcode-javascript/issues/36) -### 排序 - -[快速排序](https://github.com/sl1673495/leetcode-javascript/issues/41) - -[颜色分类-75](https://github.com/sl1673495/leetcode-javascript/issues/28) - -### 查找表 - -[两个数组的交集 II-350](https://github.com/sl1673495/leetcode-javascript/issues/37) - ### 数据结构 [LRU 缓存机制-146](https://github.com/sl1673495/leetcode-javascript/issues/35) -[实现 Trie (前缀树)-208](https://github.com/sl1673495/leetcode-javascript/issues/14) - ### 二分查找 [Pow(x, n)-50](https://github.com/sl1673495/leetcode-javascript/issues/25) From 123f28c842f9ea892a265b99db6fc3a05c193285 Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Sun, 26 Sep 2021 16:52:34 +0800 Subject: [PATCH 34/37] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 78e30a6..f7924e9 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ > 力扣的题解记录(JavaScript) +## 关于我 +大家好,我是 ssh,现在在字节跳动的 Web Infra 担任前端工程师。 + +我会在公众号「**[前端从进阶到入院](https://user-gold-cdn.xitu.io/2020/4/5/17149ccf687b7699?w=910&h=436&f=jpeg&s=78195)**」每日更新精心挑选的技术文章(标准就是我自己看了也会有收获),欢迎大家一起成长。 + ## 调试 提供了 .vscode 配置文件,在 vscode 中选择「小爬虫」图标,点击启动程序,即可启动断点调试。 From 1050a5b690d95b4fec4333a5e84c533538b65ef9 Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Sun, 26 Sep 2021 16:54:18 +0800 Subject: [PATCH 35/37] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7924e9..0fee2c7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ ## 关于我 大家好,我是 ssh,现在在字节跳动的 Web Infra 担任前端工程师。 -我会在公众号「**[前端从进阶到入院](https://user-gold-cdn.xitu.io/2020/4/5/17149ccf687b7699?w=910&h=436&f=jpeg&s=78195)**」每日更新精心挑选的技术文章(标准就是我自己看了也会有收获),欢迎大家一起成长。 +我会在公众号「前端从进阶到入院」每日更新精心挑选的技术文章(标准就是我自己看了也会有收获),欢迎大家一起成长。 + +![qrcode_for_gh_d2b31290dd8b_258](https://user-images.githubusercontent.com/23615778/134800856-9a44fa9a-4f1b-4884-a0b6-b58c5f3331df.jpg) ## 调试 From 904ac79bf001c9698dd63cefafa7fb8f0f1ca29d Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Sat, 9 Oct 2021 16:37:56 +0800 Subject: [PATCH 36/37] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fee2c7..5e4db69 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ > 力扣的题解记录(JavaScript) ## 关于我 -大家好,我是 ssh,现在在字节跳动的 Web Infra 担任前端工程师。 +大家好,我是 ssh,现在在字节跳动的 Web Infra 担任前端工程师,微信:**[sshsunlight](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/017d568dc1d14cd883cc3238350a39ec~tplv-k3u1fbpfcp-watermark.image)**,欢迎找我交个朋友。 我会在公众号「前端从进阶到入院」每日更新精心挑选的技术文章(标准就是我自己看了也会有收获),欢迎大家一起成长。 From 402a8872548bda7c1cc7d56096889d526e51fcb3 Mon Sep 17 00:00:00 2001 From: ssh <949589855@qq.com> Date: Wed, 28 Jun 2023 21:17:25 +0800 Subject: [PATCH 37/37] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e4db69..11f4963 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## 关于我 大家好,我是 ssh,现在在字节跳动的 Web Infra 担任前端工程师,微信:**[sshsunlight](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/017d568dc1d14cd883cc3238350a39ec~tplv-k3u1fbpfcp-watermark.image)**,欢迎找我交个朋友。 -我会在公众号「前端从进阶到入院」每日更新精心挑选的技术文章(标准就是我自己看了也会有收获),欢迎大家一起成长。 +一些算法相关的资料,我放在「前端从进阶到入院」公众号里了,回复「资料」即可获取。 ![qrcode_for_gh_d2b31290dd8b_258](https://user-images.githubusercontent.com/23615778/134800856-9a44fa9a-4f1b-4884-a0b6-b58c5f3331df.jpg)