Skip to content

283. Move Zeroes - #48

Open
akmhmgc wants to merge 1 commit into
mainfrom
283
Open

283. Move Zeroes#48
akmhmgc wants to merge 1 commit into
mainfrom
283

Conversation

@akmhmgc

@akmhmgc akmhmgc commented Oct 9, 2025

Copy link
Copy Markdown
Owner

解いた問題

283. Move Zeroes

使用言語

Ruby

次に解く問題

392. Is Subsequence

@akmhmgc akmhmgc added the ruby label Oct 9, 2025
Comment thread 283/step3.md
# @param {Integer[]} nums
# @return {Void} Do not return anything, modify nums in-place instead.
def move_zeroes(nums)
# leftより左には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.

ここのコメントが理解の助けになっていますが、せっかくなら変数名に反映した方がより読みやすくなると思いました。left は num_non_zero_items のような感じで、right は単に確認対象なので i でも良いと思います。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

自分もleft, rightだけだと少し分かりにくい気がしました。

Comment thread 283/step2.md

loop unrollingという言葉を初めて知った。

RubyでもArray#fillだと処理を最適化しているようだった。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ruby の場合はネイティブコードで動くかどうかのほうが速度に大きな影響を与えるでしょう。

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.

ありがとうございます。

#53 (comment)
こちらと同様ですね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants