Skip to content

Combination sum#11

Open
SuperHotDogCat wants to merge 4 commits intoarai60from
combination_sum
Open

Combination sum#11
SuperHotDogCat wants to merge 4 commits intoarai60from
combination_sum

Conversation

@SuperHotDogCat
Copy link
Copy Markdown
Owner

def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
# 書くのが安定しているwhileで書く
combinations = []
stack = [[[], 0, 0]] # current_combination, current_index, current_value
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

私は長さが固定のときには tuple にしますね。

combinations = []
stack = [[[], 0, 0]] # current_combination, current_index, current_value
while stack:
current_combination, current_index, current_value = stack.pop()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

current にほとんど情報がなく、むしろ擬態しているように見えます。

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.

つまり, どういうことでしょうか?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

https://discord.com/channels/1084280443945353267/1225849404037009609/1232382815849414656

あたりでも話しているんですが、とにかく名前の付け方に抵抗感があります。
伝える意図が感じられません。
普段一文字で書いているのを、形式的に長くしたように感じています。

@SuperHotDogCat
Copy link
Copy Markdown
Owner Author

combinations_of_sum_equals_targetの中身が数字のcombinationであることをより明確にするためにList[List[int]]を型ヒントしてみたのですがどうでしょうか

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