Sum binary tree branch? Problem from hired assessments, company: FACTUAL
Anonymous User
1202

Hello,

I am currently practicing for interviews on hired assessments which many tech companies use for interviews, and I am having an issue with a simple binary tree problem. I just have a hard time with binary trees big time.

The problem is:
image

What I have so far:

def solution(arr):
    root = arr[0]

for i in arr:
    left = sum(arr[i]-arr[0])
    right = sum(arr[i+1]-arr[0])

if left > right:
    return "Left"

elif left < right:
    return "Right"

else:
    return ""

Any help please?
Thanks

Comments (3)