I'm working on UVa #112 Tree Summing. I have what I think should be a working solution but it is not accepted by the online judge due to a basic misunderstanding of the problem on my part. Consider the following inputs:
-1 (-1()())
77 (77(1()())())
or diagrammatically, the trees look like:
-1 77
/ \ / \
() () 1 ()
/ \
() ()
According to at least two working solutions, the correct output for the above inputs is:
yes
no
However, I don't understand why the second one should be 'no'. It looks to me like the rightmost path of the tree should give the proper sum. What am I missing?