C++
文章平均质量分 71
yongfengsite
这个作者很懒,什么都没留下…
展开
-
[数据结构]求二叉树的深度与宽度
二叉树数据结构声明: struct TreeNode { int val; TreeNode *left; TreeNode *right; }; 1、递归求二叉树深度 int getDepth(TreeNode *root) { if (root == NULL) { return 0; } re原创 2015-08-09 07:44:57 · 2863 阅读 · 0 评论 -
[leetcode 70]Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 爬台阶,你每次可以上一层或者两层,问上n层你共有多少何种原创 2015-08-01 19:11:01 · 861 阅读 · 0 评论 -
[leetcode 72]Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a wor原创 2015-07-31 10:24:28 · 482 阅读 · 0 评论 -
[C++] 智能指针与循环引用
1、智能指针的出现 在我们写程序的时候总会遇到一些需要new的问题,在没有智能指针的时候,我们只能收到的去delete,一旦我们忘记就会出现内存泄漏的问题。智能指针的出现就是为了解决这一问题,让我们new的对象,能够在使用完毕之后自己delete,而不用我们手动delete。 2、智能指针的历史 1、auto_ptr(C++98) 2、unique_ptr原创 2015-09-04 08:33:15 · 1397 阅读 · 0 评论