Trendy Weeknight Dinner Recipes
Trendy Weeknight Dinner Recipes
Here are trendy, weeknight-friendly dinner ideas that are big right now and still fast
(most ~20–30 minutes):
[Link] 1/25
05/01/2026, 09:39 Example chat: Ask anything
On Linux Mint MATE (even when using Compiz), the window button position is still
controlled by Marco, the window decorator. You can move the minimize / maximize /
close buttons to the right (macOS-style) very easily.
bash
arduino
This works even if Compiz is enabled because Marco still draws the titlebar.
bash
/usr/bin/marco --replace
Copy code
[Link] 3/25
🎯 Bonus: True macOS-style (colors + spacing)
05/01/2026, 09:39 Example chat: Ask anything
If you want:
macOS-style left buttons instead
or a custom order
or help switching from Marco to another decorator
just tell me 👍
i := start
for ;i < len(inorder); i++ {
if inorder[i] == root {
break
}
}
Your snippet:
go
i := start
for ; i < len(inorder); i++ {
if inorder[i] == root {
break
Copy code
[Link] 4/25
05/01/2026, 09:39 Example chat: Ask anything
Copy code
}
}
Why it works
Go allows a for loop in this form:
go
go
Equivalent forms
Your code is equivalent to either of these:
go
or
go
But your version is the cleanest and idiomatic when i is initialized earlier.
go
i == len(inorder)
Copy code
go
if i == len(inorder) {
// root not found
}
Copy code
go
index := make(map[int]int)
for i, v := range inorder {
index[v] = i
}
Copy code
go
i := index[root]
Copy code
If you're building a tree from inorder + preorder or postorder , tell me — I can show
you the fully optimized Go solution.
[Link] 6/25
05/01/2026, 09:39 Example chat: Ask anything
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
*}
*/
func buildTree(preorder []int, inorder []int) *TreeNode {
return helper(preorder, inorder, 0, 0, len(preorder) - 1)
}
return root
Your logic idea is correct, but this Go code will panic and also build the wrong tree.
Let’s fix it cleanly and make it fast enough for LeetCode.
go
go
go
This is wrong ❌
The right subtree root is NOT ind+1 .
ini
leftSize = i - start
Copy code
So:
ini
go
func helper(preorder []int, preStart int, inStart int, inEnd int, index map
if inStart > inEnd {
return nil
}
rootVal := preorder[preStart]
root := &TreeNode{Val: rootVal}
mid := index[rootVal]
leftSize := mid - inStart
return root
}
Copy code
sql
[Link] 9/25
05/01/2026, 09:39 Example chat: Ask anything
Copy code
root | left subtree | right subtree
Inorder:
sql
So:
⏱️ Complexity
Time: O(n)
Space: O(n) (hashmap + recursion)
go
func helper(preorder []int, inorder []int, ind int, start int, end int) *Tr
if start > end {
return nil
}
return root
}
Copy code
You had:
go
[Link]
d 11/25
05/01/2026, 09:39 Example chat: Ask anything
Copy code
That crashes.
Fixed to:
go
go
go
go
to
go
[Link] 12/25
05/01/2026, 09:39 Example chat: Ask anything
Yes — you absolutely can pass ind by pointer, and it actually makes the code cleaner
for preorder traversal 👍
This avoids all the tricky index arithmetic you were just fighting with.
func helper(preorder []int, inorder []int, ind *int, start int, end int) *T
if start > end {
return nil
}
[Link] 13/25
05/01/2026, 09:39 Example chat: Ask anything
if inorder[i] == [Link] {
break
}
}
return root
Copy code
}
css
So you just:
1. Take the next preorder value as root
2. Build left subtree (it consumes preorder values)
3. Then build right subtree (continues where left stopped)
This is exactly how the recursion should flow — no index math needed.
go
(*ind)++
Copy code
NOT
go
[Link] 14/25
05/01/2026, 09:39 Example chat: Ask anything
Copy code
*ind++
go
(*ind)++
Copy code
If you want, next we can optimize it with a hashmap and make it O(n) 🚀
This is a great question — and understanding this means you’ve basically mastered how
preorder tree building really works 👌
Let’s break it down simply.
css
That means:
[Link] 15/25
05/01/2026, 09:39 Example chat: Ask anything
go
scss
root(0)
├── left(1)
└── right(1) ❌ WRONG — should be after left subtree Copy code
scss
root(0)
├── left(1 ... k)
└── right(k+1 ...)
Copy code
go
ind + 1 + leftSize
Copy code
go
ind := 0
helper(..., &ind, ...)
Copy code
So execution becomes:
sql
ind = 0 → root
ind = 1 → left root
ind = 2 → left-left
...
when left finishes, ind is now correct for right
Copy code
Without pointer:
every function gets its own copy → everyone starts reading from page 2 ❌
With pointer:
🎯 Summary
Approach Why it failed / worked
ind+1 passing Each recursion had its own index → preorder sequence breaks
❌
[Link] 17/25
05/01/2026, 09:39 Example chat: Ask anything
You accidentally discovered the cleanest recursive pattern for tree construction — this
is how it's done in serious interviews 👏
final
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
*}
*/
func buildTree(preorder []int, inorder []int) *TreeNode {
idx := 0
inOrderMap := make(map[int]int)
for i := 0; i < len(inorder); i++ {
inOrderMap[inorder[i]] = i
}
return helper(preorder, inOrderMap, &idx, 0,
len(preorder) - 1)
}
[Link] 18/25
05/01/2026, 09:39 Example chat: Ask anything
return root
❌ Bug
This line is wrong in Go:
go
*idx++
Copy code
Go parses it as:
go
*(idx++)
Copy code
✅ Correct version
You must write:
go
(*idx)++
Copy code
[Link] 19/25
05/01/2026, 09:39 Example chat: Ask anything
inOrderMap := make(map[int]int)
for i := 0; i < len(inorder); i++ {
inOrderMap[inorder[i]] = i
}
You started with a broken recursive tree and ended with a textbook optimal solution
— well done 👏
[Link] 20/25
05/01/2026, 09:39 Example chat: Ask anything
Perfect test case — let’s dry-run your exact code step-by-step so you can see why the
pointer method works.
Input
ini
We call:
arduino
idx = 0
helper(preorder, map, &idx, 0, 4)
Copy code
🧩 Step-by-step
Call 1: build root
makefile
idx = 0
root = preorder[0] = 3
mid = inorder[3] = 1
idx++ → idx = 1
Copy code
Split inorder:
[Link] 21/25
05/01/2026, 09:39 Example chat: Ask anything
ini
markdown
3
/ \
? ?
Copy code
makefile
idx = 1
root = preorder[1] = 9
mid = inorder[9] = 0
idx++ → idx = 2
Copy code
Left: empty
Right: empty
markdown
3
/ \
9 ?
Copy code
So 9 is a leaf.
makefile
idx = 2
root = preorder[2] = 20
mid = inorder[20] = 3
idx++ → idx = 3
Copy code
[Link] 22/25
05/01/2026, 09:39 Example chat: Ask anything
Split inorder:
ini
markdown
3
/ \
9 20
/ \
? ?
Copy code
makefile
idx = 3
ChatGPT 5.2
root = preorder[3] = 15
mid = inorder[15] = 2
idx++ → idx = 4
Copy code
Leaf node.
markdown
3
/ \
9 20
/
15
Copy code
makefile
idx = 4
root = preorder[4] = 7
[Link] 23/25
05/01/2026, 09:39 Example chat: Ask anything
mid = inorder[7] = 4
Copy code
idx++ → idx = 5
Leaf node.
markdown
3 Copy code
/ \
9 20
/ \
15 7
✅ Final Tree
Level order (LeetCode format):
Notice:
We never calculated where the right subtree starts.
Left subtree recursion automatically advanced idx .
When left finishes, idx is already pointing to the correct right root.
[Link] 24/25
05/01/2026, 09:39 Example chat: Ask anything
[Link] 25/25