703. Kth Largest Element in a Stream#9
Open
tNita wants to merge 1 commit into
Open
Conversation
nodchip
reviewed
Feb 3, 2026
| class MyHeap: | ||
| def __init__(self, data: list): | ||
| self.heap = data | ||
| self.heapify() |
There was a problem hiding this comment.
こちらのコメントをご参照ください。
Hiroto-Iizuka/coding_practice#17 (comment)
|
|
||
| class KthLargest: | ||
| def __init__(self, k: int, nums: List[int]): | ||
| if k < 0 or k > len(nums) + 1: |
There was a problem hiding this comment.
if not 0 <= k <= len(nums) + 1:と数直線上に一直線になるように並べると、読みやすくなると思います。
Owner
Author
There was a problem hiding this comment.
確かに頭の中に数直線をイメージしやすくなりそうですね。ありがとうございます。
TrsmYsk
reviewed
Feb 12, 2026
| - 二分探索は標準ライブラリがあるのでそちらを使う(https://docs.python.org/3/library/bisect.html) | ||
| - ただし、昇順でソートされた配列にしか適用できないので、昇順で点数配列を持っておき、後ろからk番目を答えとする必要あり | ||
| - https://github.com/python/cpython/issues/87466 | ||
| - (脱線:てかこのイシューをあげている人、提案の幅が広いな。これが専門家の選択肢の幅の広さなのかな) |
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.
この問題: 703. Kth Largest Element in a Stream
次の問題: 347. Top K Frequent Elements