A binary tree of terrain elevation samples is given in level-order form (a single line of space-separated tokens, null marking a missing child; every non-null node contributes exactly two following tokens for its children).
A node is called a peak if its value is strictly greater than the value of every child it has. A node with no children is automatically a peak (there is nothing to be greater than).
Count how many nodes in the tree are peaks.
Input format
Line 1: space-separated level-order tokens describing the binary tree (integers and the token null).
Output format
A single integer: the number of peak nodes. If the tree is empty, print 0.
Constraints
- 0 <= number of nodes <= 500
- Each node value is an integer with -1000 <= value <= 1000