mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-03 07:01:55 +08:00
Update space_complexity.md
This commit is contained in:
parent
5617f8246f
commit
ae37e902a9
@ -196,7 +196,7 @@ comments: true
|
|||||||
=== "Go"
|
=== "Go"
|
||||||
|
|
||||||
```go title=""
|
```go title=""
|
||||||
func algorithm1(n int) {
|
func algorithm(n int) {
|
||||||
a := 0 // O(1)
|
a := 0 // O(1)
|
||||||
b := make([]int, 10000) // O(1)
|
b := make([]int, 10000) // O(1)
|
||||||
var nums []int
|
var nums []int
|
||||||
@ -856,18 +856,6 @@ $$
|
|||||||
=== "Go"
|
=== "Go"
|
||||||
|
|
||||||
```go title="space_complexity.go"
|
```go title="space_complexity.go"
|
||||||
/* TreeNode 二叉树 */
|
|
||||||
type TreeNode struct {
|
|
||||||
val int
|
|
||||||
left *TreeNode
|
|
||||||
right *TreeNode
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 创建 TreeNode 结构体 */
|
|
||||||
func newTreeNode(val int) *TreeNode {
|
|
||||||
return &TreeNode{val: val}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 指数阶(建立满二叉树) */
|
/* 指数阶(建立满二叉树) */
|
||||||
func buildTree(n int) *TreeNode {
|
func buildTree(n int) *TreeNode {
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user