Skip to content

Commit bcb0be3

Browse files
committed
add 415 557 1331
1 parent 8dcbe3c commit bcb0be3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+459
-206
lines changed

assets/output/0272.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Assume that the BST is balanced, could you solve it in less than `O(n)` runtime
5353

5454
解决这个问题的一种方法是通过中序遍历得到一个按照数值升序排列的数组,然后从数组中找到距离目标值最近的 `k` 个数。这个方法的时间复杂度是 `O(n)`,其中 `n` 是树的节点数量。
5555

56+
---
57+
5658
### 思路二:二分查找
5759

5860
如果要在更短的时间内解决问题,可以利用二分搜索找到离目标值最近的节点,然后向两侧扩展,选择最接近的 `k` 个节点。在每次搜索时,由于使用了二分搜索,可以将搜索范围缩小到当前节点的左子树或右子树,这样每次搜索都能减半候选节点的数量。因此,在平衡的情况下,整体的时间复杂度是 `O(log n)`

assets/output/0415.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

assets/output/0557.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

assets/output/1331.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/.vuepress/sidebar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export default sidebar({
304304
text: "0400-0499",
305305
collapsible: true,
306306
children: [
307+
"0415",
307308
"0416",
308309
"0426",
309310
"0430",
@@ -335,6 +336,7 @@ export default sidebar({
335336
"0518",
336337
"0530",
337338
"0543",
339+
"0557",
338340
"0559",
339341
"0567",
340342
"0572",
@@ -433,6 +435,7 @@ export default sidebar({
433435
collapsible: true,
434436
children: [
435437
"1312",
438+
"1331",
436439
"1381"
437440
],
438441
},

src/leetcode/algorithm/two_pointer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@
7171
| 0925 | [长按键入](https://leetcode.com/problems/long-pressed-name/) | | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> |
7272
| 0844 | [比较含退格的字符串](https://leetcode.com/problems/backspace-string-compare/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0844) | [``](/leetcode/outline/tag/stack.md) [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) `1+` | <font color=#15bd66>Easy</font> |
7373
| 1229 | [安排会议日程](https://leetcode.com/problems/meeting-scheduler/) | | [`数组`](/leetcode/outline/tag/array.md) [`双指针`](/leetcode/outline/tag/two-pointers.md) [`排序`](/leetcode/outline/tag/sorting.md) | <font color=#ffb800>Medium</font> |
74-
| 0415 | [字符串相加](https://leetcode.com/problems/add-strings/) | | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#15bd66>Easy</font> |
74+
| 0415 | [字符串相加](https://leetcode.com/problems/add-strings/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0415) | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#15bd66>Easy</font> |
7575

src/leetcode/ds/string.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ BF 算法的思想可以用一句话来概括:在主串中检查起始位置
7979
| 0005 | [最长回文子串](https://leetcode.com/problems/longest-palindromic-substring/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0005) | [`字符串`](/leetcode/outline/tag/string.md) [`动态规划`](/leetcode/outline/tag/dynamic-programming.md) | <font color=#ffb800>Medium</font> |
8080
| 0003 | [无重复字符的最长子串](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0003) | [`哈希表`](/leetcode/outline/tag/hash-table.md) [`字符串`](/leetcode/outline/tag/string.md) [`滑动窗口`](/leetcode/outline/tag/sliding-window.md) | <font color=#ffb800>Medium</font> |
8181
| 0344 | [反转字符串](https://leetcode.com/problems/reverse-string/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0344) | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> |
82-
| 0557 | [反转字符串中的单词 III](https://leetcode.com/problems/reverse-words-in-a-string-iii/) | | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> |
82+
| 0557 | [反转字符串中的单词 III](https://leetcode.com/problems/reverse-words-in-a-string-iii/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0557) | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> |
8383
| 0049 | [字母异位词分组](https://leetcode.com/problems/group-anagrams/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0049) | [`数组`](/leetcode/outline/tag/array.md) [`哈希表`](/leetcode/outline/tag/hash-table.md) [`字符串`](/leetcode/outline/tag/string.md) `1+` | <font color=#ffb800>Medium</font> |
84-
| 0415 | [字符串相加](https://leetcode.com/problems/add-strings/) | | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#15bd66>Easy</font> |
84+
| 0415 | [字符串相加](https://leetcode.com/problems/add-strings/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0415) | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#15bd66>Easy</font> |
8585
| 0151 | [反转字符串中的单词](https://leetcode.com/problems/reverse-words-in-a-string/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0151) | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#ffb800>Medium</font> |
8686
| 0043 | [字符串相乘](https://leetcode.com/problems/multiply-strings/) | | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#ffb800>Medium</font> |
8787
| 0014 | [最长公共前缀](https://leetcode.com/problems/longest-common-prefix/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0014) | [`字典树`](/leetcode/outline/tag/trie.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> |

src/leetcode/outline/plan/codetop_list.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ headerDepth: 0
3131
| 0092 | [反转链表 II](https://leetcode.com/problems/reverse-linked-list-ii/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0092) | [`链表`](/leetcode/outline/tag/linked-list.md) | <font color=#ffb800>Medium</font> | 184 |
3232
| 0160 | [相交链表](https://leetcode.com/problems/intersection-of-two-linked-lists/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0160) | [`哈希表`](/leetcode/outline/tag/hash-table.md) [`链表`](/leetcode/outline/tag/linked-list.md) [`双指针`](/leetcode/outline/tag/two-pointers.md) | <font color=#15bd66>Easy</font> | 176 |
3333
| 0023 | [合并 K 个升序链表](https://leetcode.com/problems/merge-k-sorted-lists/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0023) | [`链表`](/leetcode/outline/tag/linked-list.md) [`分治`](/leetcode/outline/tag/divide-and-conquer.md) [`堆(优先队列)`](/leetcode/outline/tag/heap-priority-queue.md) `1+` | <font color=#ff334b>Hard</font> | 173 |
34-
| 0415 | [字符串相加](https://leetcode.com/problems/add-strings/) | | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#15bd66>Easy</font> | 166 |
34+
| 0415 | [字符串相加](https://leetcode.com/problems/add-strings/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0415) | [`数学`](/leetcode/outline/tag/mathematics.md) [`字符串`](/leetcode/outline/tag/string.md) [`模拟`](/leetcode/outline/tag/simulation.md) | <font color=#15bd66>Easy</font> | 166 |
3535
| 0300 | [最长递增子序列](https://leetcode.com/problems/longest-increasing-subsequence/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0300) | [`数组`](/leetcode/outline/tag/array.md) [`二分查找`](/leetcode/outline/tag/binary-search.md) [`动态规划`](/leetcode/outline/tag/dynamic-programming.md) | <font color=#ffb800>Medium</font> | 163 |
3636
| 0142 | [环形链表 II](https://leetcode.com/problems/linked-list-cycle-ii/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0142) | [`哈希表`](/leetcode/outline/tag/hash-table.md) [`链表`](/leetcode/outline/tag/linked-list.md) [`双指针`](/leetcode/outline/tag/two-pointers.md) | <font color=#ffb800>Medium</font> | 148 |
3737
| 0143 | [重排链表](https://leetcode.com/problems/reorder-list/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0143) | [``](/leetcode/outline/tag/stack.md) [`递归`](/leetcode/outline/tag/recursion.md) [`链表`](/leetcode/outline/tag/linked-list.md) `1+` | <font color=#ffb800>Medium</font> | 148 |
@@ -214,7 +214,7 @@ headerDepth: 0
214214
| 剑指 Offer 48 | [最长不含重复字符的子字符串](https://leetcode.cn/problems/zui-chang-bu-han-zhong-fu-zi-fu-de-zi-zi-fu-chuan-lcof/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/jz_offer_48_1) | [`哈希表`](/leetcode/outline/tag/hash-table.md) [`字符串`](/leetcode/outline/tag/string.md) [`滑动窗口`](/leetcode/outline/tag/sliding-window.md) | <font color=#ffb800>Medium</font> | 17 |
215215
| 0242 | [有效的字母异位词](https://leetcode.com/problems/valid-anagram/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0242) | [`哈希表`](/leetcode/outline/tag/hash-table.md) [`字符串`](/leetcode/outline/tag/string.md) [`排序`](/leetcode/outline/tag/sorting.md) | <font color=#15bd66>Easy</font> | 17 |
216216
| 0344 | [反转字符串](https://leetcode.com/problems/reverse-string/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0344) | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> | 17 |
217-
| 0557 | [反转字符串中的单词 III](https://leetcode.com/problems/reverse-words-in-a-string-iii/) | | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> | 17 |
217+
| 0557 | [反转字符串中的单词 III](https://leetcode.com/problems/reverse-words-in-a-string-iii/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0557) | [`双指针`](/leetcode/outline/tag/two-pointers.md) [`字符串`](/leetcode/outline/tag/string.md) | <font color=#15bd66>Easy</font> | 17 |
218218
| 0670 | [最大交换](https://leetcode.com/problems/maximum-swap/) | | [`贪心`](/leetcode/outline/tag/greedy.md) [`数学`](/leetcode/outline/tag/mathematics.md) | <font color=#ffb800>Medium</font> | 17 |
219219
| 剑指 Offer 11 | [旋转数组的最小数字](https://leetcode.cn/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/jz_offer_11_1) | [`数组`](/leetcode/outline/tag/array.md) [`二分查找`](/leetcode/outline/tag/binary-search.md) | <font color=#15bd66>Easy</font> | 17 |
220220
| 0191 | [位1的个数](https://leetcode.com/problems/number-of-1-bits/) | [JS](https://2xiao.github.io/leetcode-js/leetcode/problem/0191) | [`位运算`](/leetcode/outline/tag/bit-manipulation.md) [`分治`](/leetcode/outline/tag/divide-and-conquer.md) | <font color=#15bd66>Easy</font> | 17 |

0 commit comments

Comments
 (0)