iCIMS Interview Question

the algorithm for building the arithmetic tree