剑指 Offer 26. 树的子结构
法一 两层递归
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public boolean recur(TreeNode curA, TreeNode curB){
if(curB==null) return true;
if(curA==null) return false;
if(curA.val!=curB.val) return false;
boolean fl, fr;
fl
共有 0 条评论