Skip to content

Create 78. Subsets.md#51

Open
tokuhirat wants to merge 1 commit into
mainfrom
78.-Subsets
Open

Create 78. Subsets.md#51
tokuhirat wants to merge 1 commit into
mainfrom
78.-Subsets

Conversation

@tokuhirat
Copy link
Copy Markdown
Owner

This Problem
78. Subsets
Next Ploblem
39. Combination Sum
言語: Python

for i in range(1 << n):
subset = []
for bit, num in enumerate(nums):
if i & (1 << bit) != 0:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if i & (1 << bit) でもいいかもしれませんね。

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.

コメントありがとうございます。
i & (1 << bit) は int なので 0 と比較するのがわかりやすく、安全かなと思っています。
https://google.github.io/styleguide/pyguide.html#2144-decision

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