Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 0347.前K个高频元素.md #2542

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xqsrpanz
Copy link

对于本题目的测试用例,该判断去除没有影响,但如果将该堆的实现用于题目 [373. 查找和最小的 K 对数字](https://leetcode.cn/problems/find-k-pairs-with-smallest-sums/description/) 则会出现问题,故修复了这个问题

xqsrpanz and others added 2 commits April 26, 2024 18:01
1. 修复了 JavaScript 解法二,堆 pop 方法无法处理数组长度 <= 1 的边界情况的问题
2. 删除了有误导性的条件判断。事实上,被删除的表达式永远为真(searchChild !== undefined)。原作者想表达的意思可能是 this.queue[searchChild] !== undefined,而实际上,这个判断也是不必要的,这种情况会被后续的 this.compare(index, searchChild) > 0 判断排除。但鉴于本项目的教程性质,直接去除可能会导致语义不清,考虑酌情将原处替换为 this.queue[searchChild] !== undefined 或直接删除
@xqsrpanz xqsrpanz changed the title 修复了 JavaScript 解法二,堆 pop 方法无法处理数组长度 <= 1 的边界情况的问题 Update 0347.前K个高频元素.md Apr 26, 2024
@xqsrpanz
Copy link
Author

  1. 修复了 JavaScript 解法二,堆 pop 方法无法处理数组长度 <= 1 的边界情况的问题
  2. 删除了有误导性的条件判断。事实上,被删除的表达式永远为真(searchChild !== undefined)。原作者想表达的意思可能是 this.queue[searchChild] !== undefined,而实际上,这个判断也是不必要的,这种情况会被后续的 this.compare(index, searchChild) > 0 判断排除。但鉴于本项目的教程性质,直接去除可能会导致语义不清,考虑酌情将原处替换为 this.queue[searchChild] !== undefined 或直接删除

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.

None yet

1 participant