Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

树的子结构hasSub中有个逻辑错误 #2

Open
jayhong opened this issue Mar 11, 2020 · 0 comments
Open

树的子结构hasSub中有个逻辑错误 #2

jayhong opened this issue Mar 11, 2020 · 0 comments

Comments

@jayhong
Copy link

jayhong commented Mar 11, 2020

func hasSub(p *TreeNode, c *TreeNode) bool {
	if c == nil { return true }
	if p == nil { return false }
       
	if p.Val != c.Val {
                 // 这个地方是不是应该改成 return false
		return true
	}

	return hasSub(p.Left, c.Left) && hasSub(p.Right, c.Right)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant