Skip to content

Latest commit

 

History

History

challenge-57

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Arithmetic Binary Tree

This problem was asked by Apple.

Description

You are given a binary tree representation of an arithmetic expression. In this tree, each leaf is an integer value, and a non-leaf node is one of the four operations: '+', '-', '*', or '/'.

Write a function that takes this tree and evaluates the expression.

Example

Input:
    *
   / \
  +    +
 / \  / \
3  2  4  5

Output:
45 # (3 + 2) * (4 + 5)