摘要: 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 阅读全文
posted @ 2016-03-21 09:50 白天黑夜每日c 阅读(129) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
posted @ 2016-03-08 10:47 白天黑夜每日c 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. class Solution { public: TreeNode* invertTree(TreeNode* root) { TreeNode* temp; if(root) { temp=root->left; root->left=root->rig 阅读全文
posted @ 2016-03-08 10:27 白天黑夜每日c 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2016-03-08 10:16 白天黑夜每日c 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2016-02-24 19:47 白天黑夜每日c 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 输入:输入共有两行。第1行有3个整数,分别表示二哥的身高、凳子的高度和苹果的个数n。第2行有n个整数,分别表示每个苹果的高度。输出:输出一个整数m,表示二哥最多能摘到的苹果的个数为m。对于全部数据:高度为1000以下的正整数,苹果的个数1≤n≤10001≤n≤1000.#include using ... 阅读全文
posted @ 2016-01-22 22:28 白天黑夜每日c 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 输入:一行,两个空格隔开的整数A,B输出:一个数A+B。#include using namespace std;int main(){ int a,b; cin>>a>>b; coutscanf("%d %d",&a,&b); 阅读全文
posted @ 2016-01-22 22:03 白天黑夜每日c 阅读(108) 评论(0) 推荐(0) 编辑