Create 703. Kth Largest Element in a Stream.md#21
Open
Apo-Matchbox wants to merge 1 commit intomainfrom
Open
Conversation
nodchip
reviewed
Aug 20, 2025
|
|
||
| private: | ||
| int k_; | ||
| std::priority_queue<int, std::vector<int>, std::greater<int>> min_heap_; |
There was a problem hiding this comment.
データ構造を表す名前を変数名に入れても、あまり情報は増えないように思います。中にどのような値が含まれているかを変数名に付けたほうが読みやすくなると思います。 k_largest_values_ はいかがでしょうか?
Owner
Author
There was a problem hiding this comment.
@nodchip
ご返信随分と遅くなり大変申し訳ございません、
ご指摘頂いた通りですね。中身が何かをしっかりと意識した変数名をつけるようにします。
maeken4
reviewed
Aug 24, 2025
| * Streaming Process データが大量で、全部を保持できない。 | ||
| - 目的:stream が次々とくる。オンライン。 | ||
| - データサイズ:入力が無限に続く可能性有。全部保持したくない。 | ||
| - * k は大きい?小さい?:ここで躓いた。どのくらいの高さになるかはlognから割り出せるが、それが大きい?小さい?の判断が良くわからない。 |
There was a problem hiding this comment.
今回の問題は大学の入学試験という設定のようなので、どんなに大きくてもkは10万として、log_2(100000)≒17くらいなので小さいと考えてよさそうです。
Owner
Author
There was a problem hiding this comment.
@maeken4
こちらご返信随分と遅くなり大変申し訳ございません。
コメントありがとうございます。
推定(概算)から考えるんですね。未経験なので、あまりここら辺の感覚がわからずでして。。。
もう少し当たり前の所を気を配っていきたいと思います。
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
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.
This: https://leetcode.com/problems/kth-largest-element-in-a-stream/description/
Next: https://leetcode.com/problems/top-k-frequent-elements/description/