摘要:
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 a 阅读全文
摘要:
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
摘要:
Invert a binary tree. class Solution { public: TreeNode* invertTree(TreeNode* root) { TreeNode* temp; if(root) { temp=root->left; root->left=root->rig 阅读全文
摘要:
Given a binary tree, find its maximum depth. class Solution { public: int maxDepth(TreeNode* root) { int depth=0; if(!root) return depth; int a=maxDep 阅读全文
摘要:
class Solution { public: int DigitSum(int num){ int sum=0; do{ sum=sum+num%10; num=num/10; }while(num!=0) return sum; } int addDigits(int num) { int n 阅读全文