Count tree nodes whose value plus their children's values equals k.
Unlock detailed company stats for this questionUpgrade
The binary tree is given as a stream of n nodes in pre-order format, so you must build it first. Given an integer k, count the nodes where the sum of the node's value, its left child's value and its right child's value equals k. A simple recursive algorithm works.
Format · Online assessment.
Community answers
No answers contributed by the community yet.
Related questions
Count the subsequences whose sum equals a given target value.Related courses

Course

Course
Course
