Daily Coding 724

Good morning! Here's your coding interview problem for today.

This problem was asked by Microsoft.

Suppose an arithmetic expression is given as a binary tree. Each leaf is an integer and each internal node is one of +, , , or /.

Given the root to such a tree, write a function to evaluate it.

For example, given the following tree:


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

You should return 45, as it is (3 + 2) * (4 + 5).

compile rust version with rustc -o a.out main.rs

compile cpp version with g++ -o a.out main.cpp

compile go version with go build -o a.out main.go