文件名称:leetcodetreenode-binary-tree-paths:二叉树路径
文件大小:916B
文件格式:ZIP
更新时间:2024-07-21 03:03:46
系统开源
leetcode 树节点二叉树路径 给定一棵二叉树,返回所有从根到叶的路径。 注意:叶子是没有子节点的节点。 Example: Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] Explanation: All root-to-leaf paths are: 1->2->5, 1->3 执行 : /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { public List< String > binaryTreePaths ( TreeNode root ) { List< String > result = new ArrayList<> (); if (root == null ){ return result; } dfs(root, " " ,resul
【文件预览】:
binary-tree-paths-master
----README.md(1KB)