This solution uses a 1 dimensional array to represent the binary tree and index arithmetic to traverse it. From any node at index location `i`

, the left node is at `i+i+1`

and right node is at `i+i+2`

.

```
def pathSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
a = [None for i in xrange(32)]
for n in nums:
t = n % 100
v = n % 10
p = (t - v) / 10
d = (n - t) / 100
a[2**(d-1)-1 + (p-1)] = v
def dfs(i, s):
if a[i] == None:
return 0
s += a[i]
l = dfs(2*i + 1, s)
r = dfs(2*i + 2, s)
if l == 0 and r == 0:
return s
return l + r
s = dfs(0, 0)
return s
```