UVa #112 Tree Summing
Posted
by unclerojelio
on Stack Overflow
See other posts from Stack Overflow
or by unclerojelio
Published on 2010-03-13T03:29:47Z
Indexed on
2010/03/13
3:37 UTC
Read the original article
Hit count: 402
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?
© Stack Overflow or respective owner