Skip to content

Create 283. Move Zeroes.md#53

Open
fuga-98 wants to merge 1 commit into
mainfrom
283.-Move-Zeroes
Open

Create 283. Move Zeroes.md#53
fuga-98 wants to merge 1 commit into
mainfrom
283.-Move-Zeroes

Conversation

@fuga-98
Copy link
Copy Markdown
Owner

@fuga-98 fuga-98 commented May 28, 2025

Comment thread 283. Move Zeroes.md
> 何も書いていない except は ^C で送られてくるシグナルさえ捕まえます。
タイミングよく ^C を送ることで、括弧の対応関係を変えられるプログラム、セキュリティー的にもまずそうではないですか。
>
- けっこう書いてました。地雷を埋め込んでました。
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

まあ、そういう状況で使うことは起きないし、起きたとしたら全部書き換えるのだという覚悟が決まった上でやっているならばいいんですが、広い意味で「遠い帰結に想像がいくか」ということかなと思います。

Comment thread 283. Move Zeroes.md
i -= 1
continue
nums.append(0)
nums.pop(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.

これでi番目がpopされるの知らなかったです

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.

私も初めて使いました。O(N)かかるので注意です。
https://wiki.python.org/moin/TimeComplexity

Comment thread 283. Move Zeroes.md
continue
nums.append(0)
nums.pop(i)
i -= 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

個人的にはfor文でreversedで回す方が好みです

Comment thread 283. Move Zeroes.md
non_zero_index += 1
for i in range(non_zero_index, len(nums)):
nums[i] = 0
return nums
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

シグネチャで None を返すことになっているので、この行は不要ですね。

Comment thread 283. Move Zeroes.md
https://github.com/hroc135/leetcode/pull/51/files

- こちらは私のと似ている
- これは同意。YAGNIでしょうか。仕事でも自分の昔の実装に邪魔されることがありました。
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

YAGNI 知らなかったです。勉強になります。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What to look for in a code review にも同じことが書かれていますね。

A particular type of complexity is over-engineering, where developers have made the code more generic than it needs to be, or added functionality that isn’t presently needed by the system.

https://google.github.io/eng-practices/review/reviewer/looking-for.html#complexity

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