Skip to content

Solve 6. Zigzag Conversion#4

Open
cheeseNA wants to merge 3 commits intomainfrom
6
Open

Solve 6. Zigzag Conversion#4
cheeseNA wants to merge 3 commits intomainfrom
6

Conversation

@cheeseNA
Copy link
Copy Markdown
Owner

Problem link
参照した他の解答についてはnote.mdに記載しております.

@@ -0,0 +1,34 @@
class Solution:
def getCharFromUnitPos(self, s: str, numRows: int, unitIndex: int, position: int) -> str | None:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Python では一般には関数名・変数名は lower snake で書くと思います。詳しくは PEP8 をご覧ください。

ただ、 LeetCode のコードのひな形に合わせるのであれば、仕方ないと思います。

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.

ありがとうございます!この解答は昔書いたものなので覚えていないのですが, おそらくleetcodeに合わせてこのケースを採用したものと思います. snake_caseを採用するよう意識します.

class Solution:
def getCharFromUnitPos(self, s: str, numRows: int, unitIndex: int, position: int) -> str | None:
assert numRows >= 2
numChars = 2 * numRows - 2
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

numChars が何を表すのか分かりませんでした。 unitLength あたりはいかがでしょうか?

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.

ありがとうございます, おっしゃる通りですね. 他にもanswerといった変数名を使っており良くないですね.

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