Skip to content

Conversation

@hroc135
Copy link
Owner

@hroc135 hroc135 commented Apr 27, 2025


#### 2d
- https://github.com/usatie/leetcode/pull/2/files#diff-6df63844477a509737ffe87b2dcf17e6b85aaae820bbffe395d625625549a4ddR50
- nums[pivot] より大きい最小のインデックスを nums[pivot+1:] から探す部分は二分探索でできるじゃんと気が付いた
Copy link

Choose a reason for hiding this comment

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

これ、数が10-20くらいだとおそらく速度はそう変わりません。分岐予測が効くので線形に舐めるのは思っているよりも速いのです。
すでに pivot を探すのに線形時間かかっていることもあり、私はこれはコードの単純さを取る場面だと判断すると思います。


- Reverse を自作
- https://cs.opensource.google/go/go/+/master:src/slices/slices.go;l=472?q=func%20Reverse&ss=go%2Fgo
- 可読性について突っ込まれそうだが、実際のソースコードとほぼ同じ
Copy link

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.

3 participants