上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页
摘要: 这是leetcode上的3个题目,要求用非递归实现,其中以后序遍历实现最难,既然递归实现的三种遍历程序只需要改变输入代码顺序,为什么循环不可以呢,带着这种执拗的想法,我开始了这次研究我依然是将递归用栈来实现,而不打算使用改变二叉树结构的方法,那个我打算日后研究首先以前序遍历为例递归实现是:void ... 阅读全文
posted @ 2015-12-17 16:31 sdlwlxf 阅读(3951) 评论(0) 推荐(0) 编辑
摘要: Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ... 阅读全文
posted @ 2015-12-15 14:12 sdlwlxf 阅读(147) 评论(0) 推荐(0) 编辑
摘要: #ifndef __RED_BLACK_TREE_H__#define __RED_BLACK_TREE_H__namespace lxf { template class RedBlackTree { struct Node { enum Colo... 阅读全文
posted @ 2015-12-02 18:23 sdlwlxf 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #ifndef __BINARY_SEARCH_H__#define __BINARY_SEARCH_H__#include #include template class BinarySearchTree;template std::ostream& operator&);template cla... 阅读全文
posted @ 2015-11-27 18:48 sdlwlxf 阅读(291) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include int computeSuffixExp(char expression[], size_t len){ std::stack dump; for (int i = 0; i >> *、- >>> +、-void i... 阅读全文
posted @ 2015-11-17 14:53 sdlwlxf 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 方法一:非递归方法,利用辅助指针,时间复杂度为O(n)程序如下:template struct ListNode { Type data; ListNode* next; ListNode(Type pdata) :data(pdata), next(nullptr) {}};te... 阅读全文
posted @ 2015-11-16 14:56 sdlwlxf 阅读(1491) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2015-08-05 10:28 sdlwlxf 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 转:http://blog.csdn.net/sjf0115/article/details/8600599问题:给定一个十进制正整数N,写下从1开始,到N的所有整数,然后数一下其中出现的所有“1”的个数。例如:N= 2,写下1,2。这样只出现了1个“1”。N= 12,我们会写下1, 2, 3, 4... 阅读全文
posted @ 2015-07-18 21:59 sdlwlxf 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 全排列的递归实现虽然简单,但不容易理解。在绘制了一个树形结构图后,终于看清了里面的计算过程。但是虽然理清了过程,还是不明白为什么会这样设计。尤其是在递归调用的前后分别进行一次交换操作,感觉总是摸不着头绪。内心深处有个声音,往往让你绞尽脑汁不得其解的问题越是你的软肋。记得在高中学数学的时候,往往会因为... 阅读全文
posted @ 2015-07-14 16:53 sdlwlxf 阅读(405) 评论(0) 推荐(0) 编辑
摘要: 序号互换时间限制:1000ms | 内存限制:65535KB难度:2描述Dr.Kong设计了一个聪明的机器人卡多,卡多会对电子表格中的单元格坐标快速计算出来。单元格的行坐标是由数字编号的数字序号,而列坐标使用字母序号。观察字母序号,发现第1列到第26列的字母序号分别为A,B,…,Z,接着,第27列序... 阅读全文
posted @ 2015-07-01 22:39 sdlwlxf 阅读(421) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页