|
|
|
@ -849,7 +849,7 @@ Note that memory occupied by initializing variables or calling functions in a lo
|
|
|
|
|
const a = 0
|
|
|
|
|
b := 0
|
|
|
|
|
nums := make([]int, 10000)
|
|
|
|
|
ListNode := newNode(0)
|
|
|
|
|
node := newNode(0)
|
|
|
|
|
// 循环中的变量占用 O(1) 空间
|
|
|
|
|
var c int
|
|
|
|
|
for i := 0; i < n; i++ {
|
|
|
|
@ -859,7 +859,10 @@ Note that memory occupied by initializing variables or calling functions in a lo
|
|
|
|
|
for i := 0; i < n; i++ {
|
|
|
|
|
function()
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(a, b, nums, c, ListNode)
|
|
|
|
|
b += 0
|
|
|
|
|
c += 0
|
|
|
|
|
nums[0] = 0
|
|
|
|
|
node.val = 0
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -1938,13 +1941,13 @@ Exponential order is common in binary trees. Observe the below image, a "full bi
|
|
|
|
|
|
|
|
|
|
```go title="space_complexity.go"
|
|
|
|
|
/* 指数阶(建立满二叉树) */
|
|
|
|
|
func buildTree(n int) *treeNode {
|
|
|
|
|
func buildTree(n int) *TreeNode {
|
|
|
|
|
if n == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
root := newTreeNode(0)
|
|
|
|
|
root.left = buildTree(n - 1)
|
|
|
|
|
root.right = buildTree(n - 1)
|
|
|
|
|
root := NewTreeNode(0)
|
|
|
|
|
root.Left = buildTree(n - 1)
|
|
|
|
|
root.Right = buildTree(n - 1)
|
|
|
|
|
return root
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|