Deviopath › Go

Same Binary Tree

Hard · Data Structures

A tree node is {Val, Left, Right} encoded as nested maps (null child omitted or nil). Two trees are the same if structure and values match.

Write SameTree(a, b) that takes two map[string]any (or nil) and returns whether they represent the same tree. A missing "Left"/"Right" key is a nil child. "Val" is a number.

Next: Token Bucket Count