国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

LeetCode: same-tree

2019-11-08 03:01:14
字體:
來源:轉載
供稿:網友

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value.

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: bool isSameTree(TreeNode *p, TreeNode *q) { if(!p&&!q) return true; if(p==NULL&&q!=NULL||p!=NULL&&q==NULL||p->val!=q->val) return false; else return isSameTree(p->left,q->left)&&isSameTree(p->right,q->right); }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 明星| 崇州市| 鄯善县| 洛川县| 石家庄市| 宿迁市| 上高县| 长兴县| 德兴市| 闸北区| 西盟| 鲁甸县| 宁陵县| 伊春市| 措勤县| 饶河县| 湘阴县| 巴林右旗| 习水县| 奉化市| 西林县| 白银市| 黄山市| 南城县| 霍邱县| 临安市| 吉林省| 巴南区| 象州县| 文昌市| 长葛市| 汨罗市| 海安县| 兴城市| 高碑店市| 绥德县| 句容市| 望谟县| 鹤岗市| 兰溪市| 阳东县|