摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo 阅读全文
posted @ 2015-08-08 22:36 鸭子船长 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given two words (beginWordandendWord), and a dictionary, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only on... 阅读全文
posted @ 2015-08-07 22:18 鸭子船长 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html要想使用标准C++中string类,必须要包含#include // 注意是,不是,带.h的是C语言中的头文件using std::string;using std::... 阅读全文
posted @ 2015-08-07 21:11 鸭子船长 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文
posted @ 2015-08-05 21:39 鸭子船长 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.csdn.net/tuhuolong/article/details/6844850树的旋转,分为左旋和右旋,以下借助图来做形象的解释和介绍:1.左旋(右子为轴,当前结点左旋)如上图所示:当在某个结点pivot上,做左旋操作时,我们假设它的右孩子y不是NIL[T],pi... 阅读全文
posted @ 2015-08-05 20:14 鸭子船长 阅读(2148) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/fornever/archive/2011/12/02/2270692.html红黑树之前看了很多写红黑树的博客,但是感觉都讲的不太清楚!没说这样操作如何使他保持平衡的,于是疑惑重重,就看不下去了,一次不经意看到一个人说维基百科的红黑树讲的好,我就... 阅读全文
posted @ 2015-08-05 20:13 鸭子船长 阅读(234) 评论(0) 推荐(0) 编辑
摘要: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文
posted @ 2015-08-05 15:22 鸭子船长 阅读(480) 评论(0) 推荐(0) 编辑
摘要: Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.需考虑3类特殊情况:1、x1=x2,斜率无穷大;2、x1=x2,y1=y2,相同点也要计数,当计算最终结果... 阅读全文
posted @ 2015-07-31 16:52 鸭子船长 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.csdn.net/com_stu_zhang/article/details/7233761 一、基本概念 在计算机科学中,分治法是一种很重要的算法。字面上的解释是“分而治之”,就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题……直到最 阅读全文
posted @ 2015-07-31 15:09 鸭子船长 阅读(319) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2015-07-31 15:04 鸭子船长 阅读(114) 评论(0) 推荐(0) 编辑