Same Binary Tree
Problem statement
Two binary trees are serialized in level order. Each node value is a string and # marks a missing child. Trailing missing-child markers may be omitted.
Return whether the two serializations describe identical structure and equal values.
Function
isSameTree(firstLevelOrder: String[], secondLevelOrder: String[]) → booleanExamples
Example 1
firstLevelOrder = ["1","2","3"]secondLevelOrder = ["1","2","3"]return = trueCase 1 exercises the documented deterministic contract.
Example 2
firstLevelOrder = ["1","2"]secondLevelOrder = ["1","#","2"]return = falseCase 2 exercises the documented deterministic contract.
Example 3
firstLevelOrder = []secondLevelOrder = []return = trueCase 3 exercises the documented deterministic contract.
Constraints
0 <= firstLevelOrder.length, secondLevelOrder.length <= 200000.- Node values never equal
#. - Each serialization is structurally valid.