- 博客(65)
- 资源 (39)
- 收藏
- 关注
原创 设计模式之二十三:解释器模式
解释器模式: 给定一个语言,定义了它的文法的一种表示,并定义了一个解释器,这个解释器使用该表示来解释语言中的句子。 Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in th
2015-06-30 16:28:46 889
原创 设计模式之二十二:享元模式(FlyWeight)
享元模式: 使用共享技术有效地支持大量细粒度的对象。 Use sharing to support large numbers of fine-grained objects efficiently. 这个设计模式和它的名字一样核心是为了共享代码。UML图: 主要包括:FlyWeight:声明了一个接口,通过这个接口所有的FlyWeight能够接受并作用于外部的状态。ConcreteFl
2015-06-30 10:37:44 1105
原创 LeetCode122:Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and
2015-06-30 09:01:15 781
原创 LeetCode15:3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: Elements in a triplet (a,b,c) must be i
2015-06-29 17:10:28 612
原创 设计模式之二十一:中介者模式(Mediator)
中介者模式:定义了一个对象,用来封装一系列对象的交互。中介者模式通过使对象之间不必显式引用降低了对象之间的耦合,并且允许你独立改变它们之间的交互。中介者模式就是将对象之间的交互封装在了一个独立的对象中,这个独立的对象用来控制对象之间的交互行为,所以这个对象还是蛮复杂的。UML类图: 主要包括:Mediator:定义了一个Colleague对象之间交互的接口。ConcreteMediator:实
2015-06-28 13:25:36 1310
原创 设计模式之二十:责任链模式(Chain of Responsibility)
感觉这个设计模式和组合模式一样是一种很巧妙的设计模式,在需要使用它的地方如果不使用这种设计模式代码会变的很复杂,但是这种设计模式的基本原理又是很简单的。责任链模式: 通过使多个对象都有机会来处理请求的方式避免了请求的发送者和接收者之间的耦合。将接收者组织成链式的结构这样可以将请求沿着这条链进行传递,直到有接收者对它进行处理。UML类图: 主要包括:Handler:定义了一个处理请求的接口,实现
2015-06-27 16:06:57 939
原创 设计模式之十九:命令模式(Command)
命令模式:将一个请求封装成一个对象,从而允许用不同的请求参数化客户,对请求进行排序或记录日志,并且支持撤销操作。UML图: 主要包括:Command:声明了一个操作的接口ConcreteCommand:绑定了一个Receiver和一个行为,通过相关联的Receiver对象实现了了execute方法。Client:创建一个ConcreteCommand对象并且设置了它的Receiver。in
2015-06-27 15:02:39 919
原创 LeetCode228:Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].Credits: Special thanks to @jianchao.li.fighter for addin
2015-06-26 16:08:43 865
原创 LeetCode204:Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.计算小于n的非负整数中素数的个数。 素数又称质数,是指只能被1和它自身相除的自然数。需要注意的是1既不是素数也不是合数。2是最小的素数。使用判断一个数是否是素数的函数,那么这个函数需要进行一轮循环,在给定的小于n中又要进行一轮循环。所以时
2015-06-25 17:00:20 737
原创 LeetCode95:Unique Binary Search Trees II
Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should return all 5 unique BST’s shown below. confused what “{1,#,
2015-06-25 00:11:41 1720
原创 设计模式之十八:桥接模式(Bridge)
桥接模式: 将抽象部分和它的实现部分相分离开来,以使它们可以单独地变化。UML图: 主要包括:Abstraction:定义了抽象部分的接口,操作一个实现部分对象的引用。RefinedAbstraction:继承自抽象部分的类。Implementor:实现部分的接口。ConcreteImplementor:实现了Implementor定义的接口的具体类。C++代码如下:#include
2015-06-24 22:38:16 978
原创 LeetCode96:Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2015-06-24 15:56:10 3290
原创 LeetCode120:Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle The minimum path sum from top to
2015-06-24 13:13:09 777
原创 LeetCode226:Invert Binary Tree
nvert a binary tree. Trivia: This problem was inspired by this original tweet by Max Howell: Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on
2015-06-23 23:47:35 960
原创 LeetCode64:Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any
2015-06-23 23:11:21 733
原创 LeetCode152:Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest produ
2015-06-23 22:19:47 702
原创 LeetCode77:Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]
2015-06-23 21:45:27 823
原创 LeetCode53:Maximum Subarray
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,−5,4],the contiguous subarray [4,−1,2,1] ha
2015-06-23 11:01:49 618
原创 LeetCode221:Maximal Square
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0
2015-06-18 22:53:12 3570 3
原创 LeetCode91:Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2015-06-18 18:17:39 2664
原创 LeetCode188:Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may no
2015-06-16 15:59:17 1517
原创 LeetCode123:Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You ma
2015-06-16 09:54:29 3233
原创 设计模式之十七:单例模式(Singleton)
单例模式:确保一个类只有一个实例化的对象并且提供了一个访问这个对象的方法。UML图:主要包括:Singleton(LoadBalancer):定义了一个操作唯一的对象的方法;负责创建和操作这个唯一的对象。C++中实现单例模式是通过静态成员变量和静态方法来实现。#include class Singleton{ public: /
2015-06-15 17:04:46 753
原创 LeetCode121:Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2015-06-15 10:47:40 666
原创 LeetCode70:Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?设到第i台阶有A[i]那么到第1台阶有A[1]=
2015-06-14 23:12:43 862
原创 LeetCode213:House Robber II
Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time
2015-06-13 11:14:36 2438
原创 LeetCode192:House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
2015-06-13 09:20:18 824
原创 LeetCode63:Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the
2015-06-12 16:05:00 1215
原创 LeetCode62:Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2015-06-12 11:33:21 832
原创 LeetCode153:Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in
2015-06-11 17:03:29 597
原创 LeetCode36:Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille
2015-06-11 16:41:13 886
原创 string对象操作
标准string对象支持长度可变的字符串操作。使用它需要包含头文件,它位于std命名空间下。1.string对象的定义和初始化string s1; //默认构造函数,s1为空串string s2(s1); //将s2初始为s1的一个副本string s3("value"); //将s3初始为一个字符串字面值的副本string s4(n,'c'); //将s4初始为字符串'c'的n个副本需要注意
2015-06-11 13:26:37 773
原创 LeetCode179:Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be very large,
2015-06-11 12:46:52 672
原创 LeetCode223:Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Rectangle Area Assume that t
2015-06-10 23:39:40 1040
原创 LeetCode86:Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the
2015-06-10 16:19:57 605
原创 设计模式之十六:迭代器模式(Iterator)
迭代器模式: 提供了一种在不暴漏对象底层细节的情况下顺序访问聚合对象的方法。 Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.其实这个设计模式用的很多,但是设计的很少。因为stl中的迭代器就是这个模式的应用
2015-06-09 21:04:52 892
原创 设计模式之十五:组合模式(Composite)
组合模式: 将对象组合成树形结构来表示部分与整体的关系。组合模式让客户能将单个对象和组合对象统一对待。 Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objec
2015-06-09 19:16:16 841
原创 设计模式之十四:备忘录模式(Memento)
备忘录模式: 在不破换封装性的前提下,捕获一个对象的内部状态并将这个状态保存到对象外部,这样这个对象之后可以恢复到保存的状态。 Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state la
2015-06-09 16:28:54 801
原创 LeetCode51:N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.![这里写图片描述](http://img.blog.csdn.net/20150609105847270)Given an integer n, return
2015-06-09 11:05:22 1115
原创 LeetCode31:Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible ord
2015-06-09 10:20:07 644
计算机图形学算法
2014-09-05
TestCameraEye.rar
2014-07-04
GenerateBMP.rar
2014-07-03
PixelColor.rar
2014-07-03
TestPng.rar
2014-07-03
TestCone.rar
2014-07-03
TestCamera
2014-07-03
MFCCompositeViewer.rar
2014-01-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人