- 博客(34)
- 资源 (4)
- 收藏
- 关注
原创 设计模式—建造者模式(九)
软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 建造者模式(生成器模式):是将一个复杂的对象的构建与它的表示分离,使得同样的构建过程可以创
2017-05-31 19:44:48 389
原创 设计模式—外观模式(八)
软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 外观模式:为子系统的一组接口提供一个一致的界面,此模式定义一个高层接口,这个接口使得这一子
2017-05-31 16:34:44 387 1
原创 设计模式—模板模式(七)
软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 如果类中用了继承,并且肯定这个继承有意义,就应该要成为子类的模板,所有重复的代码都应该要上
2017-05-31 09:58:15 333 1
原创 设计模式—原型模式(六)
软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 原型模式:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象;
2017-05-30 17:25:37 360
原创 设计模式—工厂模式(五)
软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 工厂方法(Factory Method):定义一个用于创建对象的接口,让子类决定实例化哪一个
2017-05-29 19:12:20 421
原创 设计模式—代理模式(四)
代理模式(proxy):为其他对象提供一种代理以控制对这个对象的访问。优点:远程代理,可以隐藏一个对象在不同地址空间的事实 虚拟代理:通过代理来存放需要很长时间实例化的对象 安全代理:用来控制真实对象的访问权限 智能引用:当调用真实对象时,代理处理另外一些事#include #include using namespace std;//定义
2017-05-29 18:37:24 339
原创 [LeetCode]33. Search in Rotated Sorted Array
题目:Suppose a sorted array is rotatedat some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 01 2).You are given a target value to search.If found in the array return its
2017-05-26 21:56:59 293
原创 设计模式—装饰模式(三)
装饰模式 软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 动态地给一个对象添加一些额外的职责(不重要的功能,只是偶然一次
2017-05-24 22:03:20 403
原创 设计模式-设计原则
单一职责原则就一个类而言,应该仅有一个引起它变化的原因。 如果一个类承担的职责过多,就等于把这些职责耦合在一起,一个职责的变化可能会削弱或者抑制这个类完成其它职责能力。这种耦合会导制脆弱的设计,当变化发生时,设计会遭受到意想不到的破坏。 如果你能够想到多于一个的动机去改变一个类,那么这个类就具有多于一个的职责。开放封闭原则 软件实体可以扩展,但是不可修改。即对于扩展是开放
2017-05-24 21:01:45 325
原创 [LeetCode]31.nextPermutation
题目: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 possibl
2017-05-24 18:08:02 314
原创 设计模式—策略模式(二)
策略模式 软件领域中的设计模式的重要性不言而喻。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态。虽然知道这些特性的定义但是并没有做到真正的理解,这样特性有什么作用?用于什么场合中等等问题,带着疑问开始学习设计模式,主要参考《大话设计模式》和《设计模式:可复用面向对象软件的基础》两本书。 简单工厂缺点,每次增加相应子类,都要维护或者扩展这个工厂,以致
2017-05-22 23:15:38 505
原创 设计模式—简单工厂(一)
(一)简单工厂模式主要用于创建对象。新添加类时,不会影响以前的系统代码。核心思想是用一个工厂来根据输入的条件产生不同的类,然后根据不同类重载函数得到不同的结果。注意只有一个工厂,工厂根据输入参数的不同来选择不同的类实现。例子:要求写一个控制台程序,要求输入两个数和运算操作符,得到结果。通常我们可以这样写:#include#include#includeusing
2017-05-21 19:15:42 468
原创 [LeetCode]29. Divide Two Integers
题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题意:求两个数的商;有两种情况溢出:1.divisor = 0;2.dividend = INT_MIN and divisor = -1 (因为 abs
2017-05-20 22:14:04 300
原创 [LeetCode]28. Implement strStr()
题目:Implement strStr().Returns the index of the first occurrence of needle in haystack,or -1 if needle is not part of haystack.意思是:从haystack字符串中查找给定字符串needle第一次出现的位置代码如下:class Solution {pu
2017-05-20 21:53:45 375
原创 [LeetCode]27. Remove Element
题目:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory
2017-05-20 21:46:11 300
原创 [LeetCode]26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such thateach element appear only once and return the new length.Do not allocate extra space for another array,you must do this in place with
2017-05-20 21:30:44 241
原创 [LeetCode]24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.在处理这种问题时,我们通常加上一个dummy头结点指向head,至于思路很清晰了就是隔一个去交换两个
2017-05-20 21:10:37 305
转载 设计模式C++实现(1)——工厂模式
转载出处 http://blog.csdn.net/wuzhekai1985 软件领域中的设计模式为开发人员提供了一种使用专家设计经验的有效途径。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态,真正领悟设计模式的精髓是可能一个漫长的过程,需要大量实践经验的积累。最近看设计模式的书,对于每个模式,用C++写了个小例子,加深一下理解。主要参考《大话设计模式》和《设计模式:可复用面
2017-05-19 23:23:53 272
原创 [LeetCode]22. Generate Parentheses
题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:["((()))","(()())","(())()","()(())"
2017-05-18 22:22:18 328
转载 卡特兰数的详解
转载地址:http://blog.csdn.net/hackbuteer1/article/details/7450250Catalan数——卡特兰数 今天阿里淘宝笔试中碰到两道组合数学题,感觉非常亲切,但是笔试中失踪推导不出来后来查了下,原来是Catalan数。悲剧啊,现在整理一下一、Catalan数的定义令h(1)=1,Catalan数满足递归式:h(n) = h(1)*h
2017-05-18 21:54:12 1108
转载 Java面试题技术类一
Java面试题技术类一转自:http://www.cnblogs.com/shanheyongmu/p/5973402.html目录1、面向对象编程的三大特性是什么?2、String 和StringBuffer的区别3、说出ArrayList,Vector, LinkedList的存储性能和特性4、Collection 和 Collections的区
2017-05-17 21:39:44 583
转载 浅谈Arrays.asList()方法的使用
浅谈Arrays.asList()方法的使用首先,该方法是将数组转化为list。有以下几点需要注意: (1)该方法不适用于基本数据类型(byte,short,int,long,float,double,boolean) (2)该方法将数组与列表链接起来,当更新其中之一时,另一个自动更新 (3)不支持add和remove方法上代码:package com
2017-05-17 21:35:15 432
原创 [LeetCode]21. Merge Two Sorted Lists
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Definition for singly-linked list. * struct
2017-05-16 22:35:35 323
原创 [LeetCode]20.Valid Parentheses
题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid
2017-05-15 22:15:27 430
原创 [LeetCode]19. Remove Nth Node From End of List
题目:Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the link
2017-05-15 22:02:33 275
原创 [LeetCode]18.4Sum
题目:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solut
2017-05-13 17:30:08 270
原创 [LeetCode]17. Letter Combinations of a Phone Number
题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit str
2017-05-13 16:26:47 301
原创 [LeetCode]16.threeSumClosest
/*************************************************题目:找出数组中3个数和最接近Target的值For example, given array S = {-1 2 1 -4}, and target = 1.The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).*****
2017-05-13 14:28:50 399
原创 [LeetCode]15.threeSum
/************************************************* 题目:找出数组中3个数和为0的组合 For example, given array S = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [-1, -1, 2] ] **************************
2017-05-13 12:46:39 304
原创 [LeetCode]14. Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.寻找一组字符串中的最大公共字符串#include#include#includeusing namespace std;class Solution {public: string longestCom
2017-05-11 22:40:31 270
转载 boost bind使用指南
bind - boost头文件: boost/bind.hppbind 是一组重载的函数模板.用来向一个函数(或函数对象)绑定某些参数. bind的返回值是一个函数对象.它的源文件太长了. 看不下去. 这里只记下它的用法:9.1 对于普通函数假如有函数 fun() 如下: void fun(int x, int y) { cout
2017-05-09 20:23:55 301
原创 [LeetCode]13. Roman to Integer
题目:Given a roman numeral, convert it to aninteger.Input is guaranteed to be within the rangefrom 1 to 3999.代码如下://罗马数字转为int型整数 int RomanToint(string &s ) { unordered_map T = { { 'I', 1 }, {
2017-05-09 19:49:35 248
原创 [LeetCode]12. Integer to Roman
题目:Given an integer, convert it to a romannumeral.Input is guaranteed to be within the rangefrom 1 to 3999.罗马数字简介:罗马数字采用七个罗马字母作数字、即Ⅰ(1)、X(10)、C(100)、M(1000)、V(5)、L(50)、D(500)。记数的方法:相同的数字连写,所表示
2017-05-09 19:26:54 277
原创 [leetCode]11.Container With Most Water
题目:Given n non-negativeintegers a1, a2, ..., an, where eachrepresents a point at coordinate (i, ai). n verticallines are drawn such that the two endpoints of line i is at (i, ai) and (i,0). Find
2017-05-07 22:38:11 351
GCC版本window版本mingw-w64
2022-08-26
《剑指offer笔记》
2017-09-21
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人