Skip to content

Sort Colors#101

Open
tom4649 wants to merge 3 commits into
mainfrom
75.Sort-Colors
Open

Sort Colors#101
tom4649 wants to merge 3 commits into
mainfrom
75.Sort-Colors

Conversation

@tom4649
Copy link
Copy Markdown
Owner

@tom4649 tom4649 commented May 18, 2026

Comment thread 0075.Sort-Colors/step1.py Outdated
"""
Dutch National Flag: one pass, O(1) extra space.
"""
length_zero, i, length_two = 0, 0, 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 行でひとつづつ変数を定義したほうが読みやすいように感じました。

Comment thread 0075.Sort-Colors/step1.py Outdated
class Solution:
def sortColors(self, nums: list[int]) -> None:
"""
Dutch National Flag: one pass, O(1) extra space.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ドイツの国旗に例えたのは理解はできるのですが、わざわざ例える必要はないように感じました。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

オランダですね。この問題が「Dutch national flag problem」と呼ばれることがあります。

https://en.wikipedia.org/wiki/Dutch_national_flag_problem

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.

step2.py の解法はDutch national flag というアルゴリズムのようです。step2.py以外のコメントとしては不適切ですね。

https://en.wikipedia.org/wiki/Dutch_national_flag_problem

https://leetcode.com/problems/sort-colors/solutions/3464652/beats-100-cjavapythonjavascript-two-poin-d6l2

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.

3 participants