上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 72 下一页
摘要: 备忘录(Memento):在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将对象恢复到原先保存的状态。 角色: (1)Originator(发起人):创建盒子,恢复盒子。负责创建一个Memento,用以记录当前时刻它的内部状态,并可以使用备忘录恢复内部状态。O 阅读全文
posted @ 2018-12-26 15:44 乐乐章 阅读(421) 评论(0) 推荐(0)
摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文
posted @ 2018-12-26 12:28 乐乐章 阅读(192) 评论(0) 推荐(0)
摘要: 用法 1、sort函数可以三个参数也可以两个参数,必须的头文件#include < algorithm>和using namespace std; 2、它使用的排序方法是类似于快排的方法,时间复杂度为n*log2(n) 3、Sort函数有三个参数:(第三个参数可不写) (1)第一个是要排序的数组的起 阅读全文
posted @ 2018-12-25 12:54 乐乐章 阅读(890) 评论(0) 推荐(0)
摘要: Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explan 阅读全文
posted @ 2018-12-25 12:36 乐乐章 阅读(118) 评论(0) 推荐(0)
摘要: 适配器模式:将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原来由于接口不兼容而不能一起工作的那些类可以一起工作。 角色: (1)Target:这是客户所期待的接口,Target可以是具体的或抽象的类,也可以是接口。 (2)Adaptee:需要适配的类。 (3)Adapter:通过 阅读全文
posted @ 2018-12-24 16:14 乐乐章 阅读(852) 评论(0) 推荐(0)
摘要: Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digit 阅读全文
posted @ 2018-12-24 15:18 乐乐章 阅读(166) 评论(0) 推荐(0)
摘要: set c++ 如何检查一个元素是否在std :: set? 有一个更简单的等价的下面的代码: myset.find(x) != myset.end() 有一个更简单的等价的下面的代码: 检查许多STL容器中的存在的典型方法是: const bool is_in = container.find(e 阅读全文
posted @ 2018-12-24 14:41 乐乐章 阅读(1227) 评论(0) 推荐(0)
摘要: 状态模式包含如下角色: Context: 环境类 State: 抽象状态类 ConcreteState: 具体状态类 2)适用场景: a)状态模式主要解决的是当控制一个对象状态转换的条件表达式过于复杂时的情况。把状态的判断逻辑转移到表示不同状态的一系列类中,可以把复杂的判 断逻辑简单化。(简单来说, 阅读全文
posted @ 2018-12-23 22:50 乐乐章 阅读(230) 评论(0) 推荐(0)
摘要: 1、int 2 string 法1:c++11里面的to_string 法2: 2 string 2 int https://www.cnblogs.com/gaobw/p/7070622.html 阅读全文
posted @ 2018-12-23 15:08 乐乐章 阅读(174) 评论(0) 推荐(0)
摘要: The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "on 阅读全文
posted @ 2018-12-23 14:42 乐乐章 阅读(151) 评论(0) 推荐(0)
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 72 下一页