Closed
Conversation
Counting Bits
Product of Array Except Self
oda
reviewed
Dec 22, 2024
| Right: sortedArrayToBSTHalfOpenHelper(nums, mid+1, right), | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
この stack queue を使った実装 TreeNode の初期化が重複している感覚があります。
ポインターのポインターを使うとなくせますね。
https://discord.com/channels/1084280443945353267/1262688866326941718/1298575468353556501
hroc135
reviewed
Dec 28, 2024
| queue := list.New() | ||
| queue.PushBack(bstElement{root, nums[:midIndex], nums[midIndex+1:]}) | ||
| for queue.Len() > 0 { | ||
| e := queue.Remove(queue.Front()).(bstElement) |
There was a problem hiding this comment.
container/listを使ったことがなかったので質問させてください
.(bstElement)と書いているということはqueueにはbstElement以外の型の要素も入り得るということですか?- queue[1:]でRemoveを、appendでPushBackを行えるのでキューとしてcontainer/listを使うメリットがあるのかよくわからなかったです。かといってデメリットも特に思いつきません。ここら辺のメリデリってどんな感じですか?Go 言語標準ライブラリの container/list を deque として使ってみたによるとdoubly-linked-listなのでdequeueとして使う分にはメリットがありそうです。
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.
Convert Sorted Array to Binary Search Treeを解きました。レビューをお願いします。
問題:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
言語:Go
hayashi-ay/leetcode#29
sakupan102/arai60-practice#25
Mike0121/LeetCode#13
fhiyo/leetcode#26
Yoshiki-Iwasa/Arai60#28
kazukiii/leetcode#25
TORUS0818/leetcode#26
Ryotaro25/leetcode_first60#26
goto-untrapped/Arai60#48
seal-azarashi/leetcode#23
SuperHotDogCat/coding-interview#40
hroc135/leetcode#23