Notice Period

Identical Blueprints

easy

Two CAD files claim to describe the same assembly. Each is a binary tree of parts. They count as the same design only if they match node for node: same shape and same value at every position.

Given the roots of two binary trees, return True if they are structurally identical with equal values everywhere, else False.

Tests pass two level-order arrays; implement the core in _same on real nodes.

Example 1
in a = [1, 2, 3], b = [1, 2, 3]
out True
Example 2
in a = [1, 2], b = [1, null, 2]
out False
Same values, different shape: 2 hangs left in one and right in the other.
Example 3
in a = [1, 2, 1], b = [1, 1, 2]
out False
Constraints
  • · 0 <= nodes in each tree <= 100
  • · -10^4 <= node value <= 10^4
similar problem on LeetCode ↗
solution.pyloading python…
test results
Hit ▶ Run to test your code against the visible cases.