Skip to content

Commit ef4e635

Browse files
author
Joseph Luce
authored
Update 112_path_sum.md
1 parent e94eba7 commit ef4e635

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

leetcode/easy/112_path_sum.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
Keeping track of the sum as we go down the tree is one way.
99
So that when we reach a leaf node (no children), we can check the current sum against the target sum.
10-
Since its recursion, the current sum before the recursion call would be used so we don't need to subtract from the current sum.
11-
We let recursion do that for us.
10+
Since its recursion, the current sum before the recursion call would be reused if we hit a dead end, so we don't need to do any subtraction from the current sum, we let recursion do that for us.
1211

1312
Since we will be visiting all the nodes, the runtime is O(N).
1413
In the worst case, we would have to have every node on the stack if the whole tree was just a linked list, space would be O(N).

0 commit comments

Comments
 (0)