Skip to content

Commit 29795b9

Browse files
committed
fix the bug of LeetCode0113.scala
1 parent 313ebbf commit 29795b9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Scala/Tree/LeetCode0113.scala

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
class TreeNode(var _value: Int) {
32
var value: Int = _value
43
var left: TreeNode = null
@@ -9,16 +8,16 @@ object LeetCode0113 {
98
def pathSum(root: TreeNode, sum: Int): List[List[Int]] = {
109

1110
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) {
1312
return List(List(sum));
1413
}
1514
var path: List[List[Int]] = List();
16-
if (root.left != null && sum != root.value) {
15+
if (root.left != null) {
1716
path :::= pathSum(root.left, sum - root.value).map(root.value :: _);
1817
}
19-
if (root.right != null && sum != root.value) {
18+
if (root.right != null) {
2019
path :::= pathSum(root.right, sum - root.value).map(root.value :: _);
2120
}
2221
path;
2322
}
24-
}
23+
}

0 commit comments

Comments
 (0)