JAVA_Binary Tree Paths_LeetCode 257


JAVA_Binary Tree Paths_LeetCode 257

JAVA_Binary Tree Paths_LeetCode 257 풀이 class Solution { public List<String> binaryTreePaths(TreeNode root) { List<String> answer = new ArrayList<String>(); if (root != null) searchBT(root, "", answer); return answer; } private void searchBT(TreeNode root, String path, List<String> answer) { if (root.left == null && root.right == null) answer.add(path + root.val); if (root.left != null) searchBT(root.left, path + root.val + "->", answer); if (root.right != null) searchBT(root.right, path + root.v...


#BinaryTreePaths_LeetCode257 #JAVA #JAVA_BinaryTreePaths #JAVA_BinaryTreePaths_LeetCode257 #JAVA_LeetCode257

원문링크 : JAVA_Binary Tree Paths_LeetCode 257