Constructed binary tree is 10 / \ 8 2 / \ / 3 5 2
s = 21 NEW_LINE root = Node ( 10 ) NEW_LINE root . left = Node ( 8 ) NEW_LINE root . right = Node ( 2 ) NEW_LINE root . left . right = Node ( 5 ) NEW_LINE root . left . left = Node ( 3 ) NEW_LINE root . right . left = Node ( 2 ) NEW_LINE if hasPathSum ( root , s ) : NEW_LINE INDENT print " There ▁ is ▁ a ▁ root - to - leaf ▁ path ▁ with ▁ sum ▁ % d " % ( s ) NEW_LINE DEDENT else : NEW_LINE INDENT print " There ▁ is ▁ no ▁ root - to - leaf ▁ path ▁ with ▁ sum ▁ % d " % ( s ) NEW_LINE DEDENT