Day 8.2 solution.
This commit is contained in:
parent
4d567425a7
commit
656e975cb1
3 changed files with 45 additions and 4 deletions
|
@ -5,6 +5,14 @@ type Node struct {
|
|||
Metadata []int
|
||||
}
|
||||
|
||||
func (node Node) SumMetadata() int {
|
||||
sum := 0
|
||||
for _, v := range node.Metadata {
|
||||
sum += v
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
func BuildTree(data []int) *Node {
|
||||
root, _ := buildTreeR(data, 0)
|
||||
return root
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue