Skip to content

Longest Repeating Character Replacement#139

Open
tom4649 wants to merge 2 commits into
mainfrom
424.Longest-Repeating-Character-Replacement
Open

Longest Repeating Character Replacement#139
tom4649 wants to merge 2 commits into
mainfrom
424.Longest-Repeating-Character-Replacement

Conversation

@tom4649

@tom4649 tom4649 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

count = collections.defaultdict(int)
left = 0
length_of_longest = 0
heap = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heap に何が入っているのか、処理が追いづらく感じました。変数名に、要素がどのようなものかを表す英単語・英語句を付けるとよいと思いました。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントを加えました。heap だけではなく stack などにも適用できる点だと思うので頭にいれておきます。
ついでに heapq モジュールの機能を使って max heap を実現しました。

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.

2 participants