Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RakhmedovRS/bbe2bc542f73aea6d7ec035fa5313de3 to your computer and use it in GitHub Desktop.
Save RakhmedovRS/bbe2bc542f73aea6d7ec035fa5313de3 to your computer and use it in GitHub Desktop.
private boolean traverse(TreeNode root, ListNode head)
{
if (root == null)
{
return head == null;
}
if (root.val == head.val && findPath(root, head))
{
return true;
}
return traverse(root.left, head) || traverse(root.right, head);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment