You are given the roots of two binary trees. Your task is to determine whether the two trees are identical.
Two binary trees are considered identical if:
Return true if both trees are identical; otherwise, return false.
Input: root1 = [1,2,3], root2 = [1,2,3]
Output: true
Explanation: Both binary trees have the same structure and matching node values.
Input: root1 = [1,2], root2 = [1,null,2]
Output: false
Explanation: The structures of the two binary trees are different.
Input: root1 = [1,2,1], root2 = [1,1,2]
Output: false
Explanation: The corresponding node values are different, even though both trees contain the same number of nodes.
Sign in to write, run, and submit your solution against the full test suite.