MCPcopy
hub / github.com/HuberTRoy/leetCode / helper

Method helper

Tree/PathSumII.py:49–62  ·  view source on GitHub ↗
(prev, root, sum, path)

Source from the content-addressed store, hash-verified

47 result = []
48
49 def helper(prev, root, sum, path):
50 if prev + root.val == sum:
51 if not root.left and not root.right:
52 result.append(list(map(int, path.split(' ')[1:]))+[root.val])
53 return True
54
55 if root.left:
56 helper(prev + root.val, root.left, sum, path=path+" "+str(root.val))
57 # return True
58
59 if root.right:
60 helper(prev + root.val, root.right, sum, path=path+" "+str(root.val))
61
62 return False
63
64 helper(0, root, sum, "")
65

Callers

nothing calls this directly

Calls 2

splitMethod · 0.80
helperFunction · 0.50

Tested by

no test coverage detected