File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
-
2
1
class TreeNode (var _value : Int ) {
3
2
var value : Int = _value
4
3
var left : TreeNode = null
@@ -9,16 +8,16 @@ object LeetCode0113 {
9
8
def pathSum (root : TreeNode , sum : Int ): List [List [Int ]] = {
10
9
11
10
if (root == null ) return List ();
12
- if (root != null && root.left == null && root.right == null && sum == root.value) {
11
+ if (root != null && root.left == null && root.right == null && sum == root.value) {
13
12
return List (List (sum));
14
13
}
15
14
var path : List [List [Int ]] = List ();
16
- if (root.left != null && sum != root.value ) {
15
+ if (root.left != null ) {
17
16
path :::= pathSum(root.left, sum - root.value).map(root.value :: _);
18
17
}
19
- if (root.right != null && sum != root.value ) {
18
+ if (root.right != null ) {
20
19
path :::= pathSum(root.right, sum - root.value).map(root.value :: _);
21
20
}
22
21
path;
23
22
}
24
- }
23
+ }
You can’t perform that action at this time.
0 commit comments