Skip to content

Commit e270078

Browse files
committed
github.com/masx200/leetcode-test/maximum-binary-tree
1 parent 3b32371 commit e270078

File tree

8 files changed

+63
-0
lines changed

8 files changed

+63
-0
lines changed

maximum-binary-tree-ii/export.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package index
2+
3+
func InsertIntoMaxTree(root *TreeNode, val int) *TreeNode {
4+
return insertIntoMaxTree(root, val)
5+
}

maximum-binary-tree-ii/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module github.com/masx200/leetcode-test/maximum-binary-tree-ii
2+
3+
go 1.19
4+
5+
require github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree v0.0.0
6+
7+
replace github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree v0.0.0 => ../serialize-and-deserialize-binary-tree

maximum-binary-tree-ii/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
2+
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=

maximum-binary-tree-ii/index.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package index
2+
3+
import serialize_and_deserialize_binary_tree "github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree"
4+
5+
type TreeNode = serialize_and_deserialize_binary_tree.TreeNode
6+
7+
func insertIntoMaxTree(root *TreeNode, val int) *TreeNode {
8+
if root == nil || root.Val < val {
9+
return &TreeNode{Val: val, Left: root}
10+
11+
}
12+
13+
root.Right = insertIntoMaxTree(root.Right, val)
14+
return root
15+
}

maximum-binary-tree/export.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package index
2+
3+
func ConstructMaximumBinaryTree(nums []int) *TreeNode {
4+
return constructMaximumBinaryTree(nums)
5+
}

maximum-binary-tree/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/masx200/leetcode-test/maximum-binary-tree
2+
3+
go 1.19
4+
5+
require github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree v0.0.0
6+
7+
require github.com/masx200/leetcode-test/maximum-binary-tree-ii v0.0.0
8+
9+
replace github.com/masx200/leetcode-test/maximum-binary-tree-ii v0.0.0 => ../maximum-binary-tree-ii
10+
11+
replace github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree v0.0.0 => ../serialize-and-deserialize-binary-tree

maximum-binary-tree/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
2+
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=

maximum-binary-tree/index.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package index
2+
3+
import maximum_binary_tree_ii "github.com/masx200/leetcode-test/maximum-binary-tree-ii"
4+
import serialize_and_deserialize_binary_tree "github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree"
5+
6+
type TreeNode = serialize_and_deserialize_binary_tree.TreeNode
7+
8+
var insertIntoMaxTree = maximum_binary_tree_ii.InsertIntoMaxTree
9+
10+
func constructMaximumBinaryTree(nums []int) *TreeNode {
11+
var node *TreeNode = nil
12+
for _, v := range nums {
13+
node = insertIntoMaxTree(node, v)
14+
}
15+
return node
16+
}

0 commit comments

Comments
 (0)