Skip to content

Create 0039-combination-sum.md - #53

Open
naoto-iwase wants to merge 1 commit into
mainfrom
0039-combination-sum
Open

Create 0039-combination-sum.md#53
naoto-iwase wants to merge 1 commit into
mainfrom
0039-combination-sum

Conversation

@naoto-iwase

Copy link
Copy Markdown
Owner


if added == remain:
results.append(combination)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ここの continue はなくても大丈夫かなと思いました。

while stack:
combination, remain, index = stack.pop()

for i in range(index, len(ascendings)):

@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.

趣味の範囲かもしれませんが、ここの i と index は少し紛らわしく感じるかもしれないと思いました。start や start_index なども選択肢としてよさそうかなと思いました。(index を start にするという意味になります。)

stack.append((combination + [added], total + added, index))

return results
```

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/1196472827457589338/1232733730280575017
- > 答えの数ですが、candidates = [1..target] の場合、これは分割数というものですね。
- https://oeis.org/A000041
- 計算量の評価、複雑そうだったのでサボってしまった。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

分割数の極限の話は普通知らない上に、かなりややこしいです。撤退していいと思います。

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