- 博客(6)
- 资源 (2)
- 收藏
- 关注
原创 lintcode--摊平嵌套的列表
题目:给你一个嵌套的列表,实现一个迭代器将其摊平。一个列表的每个元素可能是整数或者一个列表。样例给出列表 [[1,1],2,[1,1]],经过迭代器之后返回 [1,1,2,1,1]。给出列表 [1,[4,[6]]],经过迭代器之后返回 [1,4,6]。解答:该题属于使用给定的数据类型和方法,使用queue进行BFS,递归解决问题。/** * // This is
2017-06-19 19:38:11 320
原创 lintcode--Expression Expand
题目:Given an expression s includes numbers, letters and brackets. Number represents the number of repetitions inside the brackets(can be a string or another expression).Please expand expression to be
2017-06-19 19:02:59 838
转载 智能指针
转自知乎:http://www.zhihu.com/question/20368881智能指针和普通指针的区别在于智能指针实际上是对普通指针加了一层封装机制,这样的一层封装机制的目的是为了使得智能指针可以方便的管理一个对象的生命期。在C++中,我们知道,如果使用普通指针来创建一个指向某个对象的指针,那么在使用完这个对象之后我们需要自己删除它,例如:ObjectType*
2015-09-05 22:43:52 349
转载 leetcode——Generate Parentheses
原问题连接 https://leetcode.com/problems/generate-parentheses/符合该问题的解需要满足一个原则:在某个位置k前,左括号的个数大于等于右括号的个数。具体可以分为以下三种情况:(1)剩余左括号的个数和剩余右括号的个数都为0,组成一个合法的结果;(2)剩余左括号的个数大于0,可以插入左括号;(3)剩余右括号的个数大于0,并且剩余左
2015-06-21 22:27:00 296
原创 关于C++编译器对于字符串变量的地址分配
int main(){ const char str[] = "hello"; const char str1[] = "hello"; const char *pstr = "hello"; const char *pstr1 = "hello"; int count = 1; if ("hello" == str) count ++; if (strcmp("hello"
2015-04-18 14:34:43 375
转载 二级指针的使用——二叉树的创建
二叉树的创建typedef struct node{ char data; struct node *lchild, *rchild;}Node,*pNode;创建形式一:int buildTree(pNode &T){ char data; cin >> data; if (data == '#') T = NULL; else{ T = (pNode)mall
2014-12-17 15:05:12 1207
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人