You are given the root of a binary tree. Your task is to count the number of non-leaf (internal) nodes.
A non-leaf node is a node that has at least one child.
Return the total number of nodes that are not leaf nodes.
Input: root = [1,2,3,4,5]
Output: 2
Explanation: Nodes 1 and 2 have children; nodes 3, 4, and 5 are leaves. So there are 2 non-leaf nodes.
Input: root = [1]
Output: 0
Explanation: A single node is a leaf, so there are no non-leaf nodes.
Input: root = []
Output: 0
Explanation: An empty tree has no non-leaf nodes.
Sign in to write, run, and submit your solution against the full test suite.