Count univalue subtrees and Search in rotated sorted array
Given a binary tree, determine how many subtrees have all nodes containing the same value.
A subtree is considered uniform if every node in that subtree holds an identical value.
Example 1: Input: root = [4,3,4,4,4,null,4] 4 / \ 3 4 / \ \ 4 4 4 Output: 4 Here are the 4 uni-value subtrees from the input tree. Each of these subtrees has all nodes with the same value: A single node with value 4 (rightmost leaf). A single node with value 4 (left child of 3). A single node with value 4 (right child of 3). A subtree rooted at the right child of the root (4) with its own right child 4.
Example 2: Input: root = [2,2,2,2,null,null,2] 2 / \ 2 2 / \ 2 2 Output: 5