Skip to content

108. Convert Sorted Array to Binary Search Tree#24

Open
TakayaShirai wants to merge 1 commit intomainfrom
108_convert_sorted_array_to_binary_search_tree
Open

108. Convert Sorted Array to Binary Search Tree#24
TakayaShirai wants to merge 1 commit intomainfrom
108_convert_sorted_array_to_binary_search_tree

Conversation

@TakayaShirai
Copy link
Copy Markdown
Owner

@TakayaShirai TakayaShirai self-assigned this Feb 15, 2026
return null;
}

final midIndex = nums.length ~/ 2;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dartだとinteger divisionはこう書けるんですね。勉強になります。

// 再帰の方が直感的ですぐ書けるが、感覚的に書けるやつ練習してもあまり意味がないので、面倒な方で書く。
class Solution {
TreeNode? sortedArrayToBST(List<int> nums) {
TreeNode? buildRoot(List<int> 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.

build と聞くとまあまあ複雑な処理を想像しました。これなら pick などもう少し軽い処理を連想させる単語を使ってもいいかもしれません。

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.

レビューありがとうございます!

確かに pick の方が操作の意味と合っている感じがして良いですね。参考になります。

@mamo3gr
Copy link
Copy Markdown

mamo3gr commented Feb 17, 2026

特に違和感ありませんでした 👍 私はDartは馴染みが無いのですが、それでもスッと読めるくらい毎回分かりやすく書いてくださってありがとうございます。

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