Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在本题的原版哈希解法中,如果对样例进行测试,会发现输出的
[a, b, c]
并不是递增顺序,如图。这并不影响判题,但是这反映出了一个问题,原题解把
b
和c
写反了,导致这部分的注释也是错的。本题的unordered_set
事实上存储的是b
,而不是c
。对于内层循环,上轮拿到的数,如果在else
分支中被存储进unordered_set
,本轮循环拿到的数实际上大于等于unordered_set
中的所有数,所以本轮拿到的是c
,unordered_set
中是b
,这样才符合大小关系。此外,本 pr 补充了对于三段去重代码的详细解释,完整代码如下。
其他语言的哈希解法或许也需要相应修改。