Skip to content

Random Pick With Weight - #158

Open
tom4649 wants to merge 2 commits into
mainfrom
528.Random-Pick-with-Weight
Open

Random Pick With Weight#158
tom4649 wants to merge 2 commits into
mainfrom
528.Random-Pick-with-Weight

Conversation

@tom4649

@tom4649 tom4649 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

class Solution:

def __init__(self, w: list[int]):
self.cumsum = list(itertools.accumulate(w))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

cumsum は numpy の関数名だと思うのですが、ソフトウェアエンジニアの常識に含まれているかどうか微妙に感じます。 cumulative_sum とフルスペルで書いたほうが無難だと思います。

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.

そうですね、numpy に影響されたと思います。変数名は基本省略しないで書くことを意識します。
(step2 では prefix_sums としました)

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