A Thinking Ape Interview Question: Given a binary tree of intege... | Glassdoor.ca

Interview Question

Software Engineer Interview(Student Candidate) Toronto, ON

Given a binary tree of integer values, return True if there

  are any partial or complete paths down the tree's root such that the sum of the values along the path sum up to the value of the root, and False otherwise.

Interview Answer

1 Answer


Recursive solution — trick was to subtract down the child node value from the root value and check if it is zero, else call function again on the left child and right child subtracting down each child's child node value from the root value minus the child node value and so on.

Interview Candidate on 2017-04-17

Add Answers or Comments

To comment on this, Sign In or Sign Up.