摘要: 1、函数名:memset 所属头文件: 用法:void*memset(void*s,charch,unsignedn);对于对int之类的数组,只能用memset对其初始化为0或-1初始化,如:1 int a[]; 2 memset(a,0,sizeof(a)):3 //sizof(a)=sizeof(int)*n; 而对于char型,可以赋任何字符。如:1 char a[]; 2 memset(a,'0',sizeof(a));//sizeof(a)=1*n;2、函数名:fill_n 所属头文件: 用法:template voidfill_n(OutputIt first, 阅读全文
posted @ 2013-11-02 17:05 hbiner 阅读(482) 评论(0) 推荐(0)
摘要: 题目链接:http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.解法:递归;父节点的深度等于左子树/右子树中深度大者+1 1 /** 2 * Definition for binary tree 3 * stru.. 阅读全文
posted @ 2013-11-02 16:57 hbiner 阅读(151) 评论(0) 推荐(0)
摘要: 题目链接:http://oj.leetcode.com/problems/single-number-ii/Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?解法:由于数组中所有元素都是整型,整型长度为32位,可以用一个数组count 阅读全文
posted @ 2013-11-02 16:51 hbiner 阅读(190) 评论(0) 推荐(0)