国产探花免费观看_亚洲丰满少妇自慰呻吟_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); }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 明溪县| 辽阳市| 从化市| 延长县| 许昌市| 蒙山县| 洞头县| 荆州市| 库车县| 隆回县| 江安县| 饶河县| 同心县| 金堂县| 屏山县| 鲁甸县| 永胜县| 沂南县| 长白| 城固县| 来凤县| 夏邑县| 务川| 岳西县| 德保县| 静乐县| 绥阳县| 周至县| 五原县| 邓州市| 青川县| 宾阳县| 聂拉木县| 双柏县| 梅州市| 肇州县| 怀宁县| 辉县市| 毕节市| 揭阳市| 米林县|