Skip to content

49. Group Anagrams - #12

Open
kazizi55 wants to merge 1 commit into
mainfrom
49-group-anagrams
Open

49. Group Anagrams#12
kazizi55 wants to merge 1 commit into
mainfrom
49-group-anagrams

Conversation

@kazizi55

Copy link
Copy Markdown
Owner

@kazizi55
kazizi55 marked this pull request as ready for review July 12, 2026 14:15

@miyataka miyataka left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

読みやすくてよかったです

counts = [0] * 26
for c in s:
alphabet_index = ord(c) - ord("a")
if not 0 <= alphabet_index < 26:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

この評価ができない文字コードも一応存在します。

参考:
chryschron/codings#15 (comment)

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.

ありがとうございます。知らなかったので勉強になりました。
確かにa–i (0x81–0x89), j–r (0x91–0x99), s–z (0xA2–0xA9)のような感じでところどころ1飛ばしになっていますね!
https://en.wikipedia.org/wiki/EBCDIC

## Step 3

- Step 2の解法1で解いた。
- 実装がシンプルで分かりやすいのと、"".join(sorted(s)) を使うよりもワンライナーで書いた時の認知負荷が若干こっちの方が低い気がしたのでこちらが好み。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

個人的には "".join(sorted(s)) の方が馴染みがありますが、好みの範囲かもしれません。

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.

list を str に変える方が、色んなことに転用される可能性が多い という理由で私は tuple を使う方が好みと書いていましたが、どちらがいろんなことに転用されうるかというのは読み手の考え方次第だなと思い直したので、確かに好みの範囲かもですね。

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.

4 participants