FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs: clarify kth largest complexity by Snailclimb · Pull Request #2901 · Snailclimb/JavaGuide · GitHub

docs: clarify kth largest complexity - #2901

Closed
Snailclimb wants to merge 1 commit into
mainfrom
codex/clarify-kth-largest-complexity
Closed

docs: clarify kth largest complexity#2901
Snailclimb wants to merge 1 commit into
mainfrom
codex/clarify-kth-largest-complexity

Conversation

Copy link
Copy Markdown
Owner

修改内容

  • 明确大小为 K 的小顶堆求第 K 大的时间复杂度为 O(nlogk)、空间复杂度为 O(k)
  • 区分通用/数据流场景与一次性数组的线性时间要求
  • 说明随机化快速选择的期望时间复杂度为 O(n),以及 BFPRT 的最坏 O(n) 保证
  • 在 LeetCode 215 推荐项旁补充快速选择提示

原因

原文把维护大小为 K 的小顶堆作为“求第 K 大”的常见方案,但没有说明该方案不满足 LeetCode 215 的 O(n) 时间复杂度要求,容易让读者把通用 Top K 解法与特定题目的复杂度约束混淆。

验证

  • pnpm exec prettier --check docs/cs-basics/data-structure/heap.md
  • pnpm exec markdownlint-cli2 docs/cs-basics/data-structure/heap.md
  • git diff --check

Closes #2899

Copy link
Copy Markdown
Owner Author

按当前维护安排,改动改为本地统一整理,不通过独立 PR 提交,因此关闭此 Draft PR。

Snailclimb closed this Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

关于“求第 K 大”小顶堆解法与 LeetCode 215.数组中的第K个最大元素时间复杂度要求的疑问

1 participant


Back | FazBrowse Home | New Git URL