2016年6月24日

2016.6.24——vector<vector<int>>【Binary Tree Level Order Traversal】

摘要: Binary Tree Level Order Traversal 本题收获: 1.vector<vector<int>>的用法 vector<vector<int> >注意<int>后面的空格,vector<vector<int>>表示的是二位向量。 输出格式(后面代码),不知道大小时,在vect 阅读全文

posted @ 2016-06-24 15:26 zhuzhu2016 阅读(385) 评论(0) 推荐(0) 编辑

2016年6月21日

2016.6.21——Climbing Stairs

摘要: Climbing Stairs 本题收获: 1.斐波那契函数f(n) = f(n-1) + f(n -2) 题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can eithe 阅读全文

posted @ 2016-06-21 14:52 zhuzhu2016 阅读(210) 评论(0) 推荐(0) 编辑

2016.6.21——Add Binary

摘要: Add Binary 本题收获: 对于相加而言,考虑进位以及进位之后的值为多少,全部进位完毕后进位还为1(11 + 11 = 110)需要添加一位.1.string中默认每个元素为char型 2.从int型转化为char型 s[i] - '0' 从char型转化为int型 s[i] + '0' 3. 阅读全文

posted @ 2016-06-21 14:42 zhuzhu2016 阅读(132) 评论(0) 推荐(0) 编辑

2016年6月20日

2016.6.20——Plus One

摘要: Plus One 本题收获 1.vector<int> 和vector<char>的区别,及与int转换 从vector<int> nums 转换为int res型,直接for循环 res += nums[i];(nums中的数本就是int型,不需要再-‘0’,char型则需要用nums[i] 的A 阅读全文

posted @ 2016-06-20 17:17 zhuzhu2016 阅读(333) 评论(0) 推荐(0) 编辑

2016年6月19日

2016.6.19——Length of Last Word

摘要: Length of Last Word 本题收获: 1.str.size()为负 2.size_t引发的死循环 3.题目思路,有时在写代码时很不清楚边界条件的输出值是什么,若为面试,一定要问清楚。 题目: Given a string s consists of upper/lower-case a 阅读全文

posted @ 2016-06-19 20:26 zhuzhu2016 阅读(145) 评论(0) 推荐(0) 编辑

2016.6.19——C++杂记

摘要: C++杂记 补充的小知识点: 1.while(n--)和while(--n)区别: while(n--)即使不满足也执行一次循环后跳出。 while(--n)不满足直接跳出循环,不执行语句。 用cout << n << endl就可以看到,加入输入n = 3 while(n--) :执行完减1后,执 阅读全文

posted @ 2016-06-19 14:47 zhuzhu2016 阅读(193) 评论(0) 推荐(0) 编辑

2016年6月18日

2016.6.18——Implement strStr()

摘要: Implement strStr() 本题收获: 1.考虑多种边界条件。 2.haystack.size() size_type 是无符号的,即为正数 在32位系统上定义为 unsigned int 在64位系统上定义为 unsigned long 两个size相减若<0,则直接出现以下情况: 并不 阅读全文

posted @ 2016-06-18 18:25 zhuzhu2016 阅读(141) 评论(0) 推荐(0) 编辑

2016年6月17日

2016.6.17——Valid Parentheses

摘要: Valid Parentheses 本题收获: 1.stack的使用 2.string和char的区别 题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if th 阅读全文

posted @ 2016-06-17 19:52 zhuzhu2016 阅读(219) 评论(0) 推荐(0) 编辑

2016.6.17——Remove Duplicates from Sorted Array

摘要: Remove Duplicates from Sorted Array 本题收获: 1.“删除”数组中元素 2.数组输出 题目: Given a sorted array, remove the duplicates in place such that each element appear on 阅读全文

posted @ 2016-06-17 19:21 zhuzhu2016 阅读(173) 评论(0) 推荐(0) 编辑

2016年6月1日

2016.6.1——Min Stack

摘要: Min Stack 本题收获: 1.可以利用两个栈操作。 2.栈的基本操作。 题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) - 阅读全文

posted @ 2016-06-01 22:53 zhuzhu2016 阅读(152) 评论(0) 推荐(0) 编辑

导航