We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 88650bf + f226234 commit c5407ceCopy full SHA for c5407ce
2019.01.14-leetcode257/sourcema.md
@@ -0,0 +1,25 @@
1
+# leetcode 257
2
+ class Solution {
3
+ public List<String> binaryTreePaths(TreeNode root) {
4
+ List<String> list = new ArrayList<>();
5
+ if (root == null) {
6
+ return list;
7
+ }
8
+ dfs(root, list,new String());
9
10
11
+ private void dfs(TreeNode root, List<String> list,String ret) {
12
+ if (root.left==null&&root.right==null) {
13
+ ret+=root.val;
14
+ list.add(ret);
15
+ return;
16
17
+ ret += root.val + "->";
18
+ if(root.left!=null){
19
+ dfs(root.left,list,ret);
20
21
+ if(root.right!=null){
22
+ dfs(root.right,list,ret);
23
24
25
0 commit comments