You’re given the root of a binary tree (unique values) and two distinct target values x and y.
Two nodes are cousins if they are at the same depth but have different parents.
Return true if the nodes with values x and y are cousins; otherwise return false.
Depth of root is 0.
Input: root = [1,2,3,4], x = 4, y = 3
Output: false
Input: root = [1,2,3,null,4,null,5], x = 5, y = 4
Output: true
Input: root = [1,2,3,null,4], x = 2, y = 3
Output: false
Accepted:
Submission: