Skip to content

Create 0046-permutations.md - #51

Open
naoto-iwase wants to merge 1 commit into
mainfrom
0046-permutations
Open

Create 0046-permutations.md#51
naoto-iwase wants to merge 1 commit into
mainfrom
0046-permutations

Conversation

@naoto-iwase

Copy link
Copy Markdown
Owner


while stack:
path = stack.pop()
if len(path) == len(nums):

@shintaro1993 shintaro1993 Nov 3, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

リストの長さの比較では微妙かもしれませんが、もし nums の代替として set_nums を用意したのであればループの中では len(set_nums) とするのもいいかもしれないと思いました。もしくは set_nums が何に使われる変数なのか(remaining などのように)が名前からもう少しわかるとうれしいなと思いました。

class Solution:
def permute(self, nums: list[int]) -> list[list[int]]:
all_patterns = []
path = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

path や traverse_remainings は操作の形式からつけている名前で、操作の意味からつけると premutation_prefix や build_permutation のような感じになると思いました。形式から変数名をつける場合はコメントでやろうとしていることを書いた方が意味と対応させやすく読みやすいように思いました。

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