FastPrepSame Binary Tree
Problems/Same Binary Tree

Same Binary Tree

Odoo logoOdoo● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task identifies this algorithmic exercise. The executable interface, bounds, deterministic tie rules, and examples are the documented practice contract.

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[]) → boolean

Examples

Example 1

firstLevelOrder = ["1","2","3"]secondLevelOrder = ["1","2","3"]return = true

Case 1 exercises the documented deterministic contract.

Example 2

firstLevelOrder = ["1","2"]secondLevelOrder = ["1","#","2"]return = false

Case 2 exercises the documented deterministic contract.

Example 3

firstLevelOrder = []secondLevelOrder = []return = true

Case 3 exercises the documented deterministic contract.

Constraints

  • 0 <= firstLevelOrder.length, secondLevelOrder.length <= 200000.
  • Node values never equal #.
  • Each serialization is structurally valid.

More Odoo problems

  • Compare Character Arrays with BackspacesOA · Seen Sep 2024
  • Employees Joined per MonthOA · Seen Sep 2024
  • Evaluate a Python Integer ExpressionOA · Seen Sep 2024
All Odoo interview questionsSee Odoo hiring insights
Saved
class Solution {
    public boolean isSameTree(String[] firstLevelOrder, String[] secondLevelOrder) {
        // Write your code here.
    }

}
Checking account…