Skip to content

Commit dd56d54

Browse files
refactor 257
1 parent 718158f commit dd56d54

File tree

1 file changed

+2
-18
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-18
lines changed

src/main/java/com/fishercoder/solutions/_257.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,11 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8-
/**257. Binary Tree Paths
9-
*
10-
Given a binary tree, return all root-to-leaf paths.
11-
12-
For example, given the following binary tree:
13-
14-
1
15-
/ \
16-
2 3
17-
\
18-
5
19-
All root-to-leaf paths are:
20-
21-
["1->2->5", "1->3"]
22-
*/
23-
248
public class _257 {
259
public static class Solution1 {
2610
//a very typical/good question to test your recursion/dfs understanding.
2711
public List<String> binaryTreePaths_more_concise(TreeNode root) {
28-
List<String> paths = new ArrayList<String>();
12+
List<String> paths = new ArrayList<>();
2913
if (root == null) {
3014
return paths;
3115
}
@@ -50,7 +34,7 @@ private void dfs(TreeNode root, List<String> paths, String path) {
5034

5135
public static class Solution2 {
5236
public List<String> binaryTreePaths(TreeNode root) {
53-
List<String> paths = new ArrayList<String>();
37+
List<String> paths = new ArrayList<>();
5438
dfs(root, paths, new StringBuilder());
5539
return paths;
5640
}

0 commit comments

Comments
 (0)