Conversation
nodchip
reviewed
Feb 9, 2026
| - https://github.com/05ryt31/leetcode/pull/15 | ||
| - コードの出力は自分と似ていたので感覚は近そう | ||
| - https://github.com/mamo3gr/arai60/pull/23/changes | ||
| - 配列の範囲の終点を扱うのに、開区間と閉区間の方がある(始点は閉区間でいいだろう)。Pythonのインデックスに従うなら開区間だが、閉区間の方が(個人的には)扱いやすくバグのリスクが減らせそう。「リーダブルコードで」、開区間なら `begin, end`, 閉区間なら `start, last` を使う、という命名を思い出す。→書いてみたら「中央の要素を抜いた、配列の左右がそれぞれ存在するかどうか」の分岐条件が違うだけみたいだった。 |
There was a problem hiding this comment.
半開区間なら begin, end をよく見かけるように感じます。 C++ のイテレーターはこのパターンです。
| # self.right = right | ||
| class Solution: | ||
| def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]: | ||
| binary_root = None |
There was a problem hiding this comment.
他と区別する必要がないため、 binary_ という接頭辞は省略しても十分伝わると思いました。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This problem
https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/description/
Next problem
https://leetcode.com/problems/path-sum/description/