提交 134c5e0e 编写于 作者: 梦境迷离's avatar 梦境迷离

fix Leetcode_JZ_26

上级 0cbb159b
......@@ -17,14 +17,14 @@ object Leetcode_JZ_26 {
*/
fun isSubStructure(A: TreeNode?, B: TreeNode?): Boolean {
if (A == null || B == null) return false
return isSubTree(A, B) || isSubStructure(A?.left, B) || isSubStructure(A?.right, B)
return isSubTree(A, B) || isSubStructure(A.left, B) || isSubStructure(A.right, B)
}
private fun isSubTree(a: TreeNode?, b: TreeNode?): Boolean {
if (b == null) return true
if (a == null) return false
if (a.`val` != b.`val`) return false
return isSubTree(a?.left, b?.left) && isSubTree(a?.right, b?.right)
return isSubTree(a.left, b.left) && isSubTree(a.right, b.right)
}
@JvmStatic
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册