Happiness is more than pleasure without pain

你只有非常努力,才能看起来毫不费力

导航

2015年3月29日 #

适配器模式和代理模式:

摘要: 代理模式:class B { A a; public B(){a=new A();} f(){a.f()}}B b=new B();b.f();//实质就是调用A的f方法适配器模式:class B implements AA{ AA a =new A(); f(){a.f()}}AA aa=new ... 阅读全文

posted @ 2015-03-29 10:39 believer 阅读(164) 评论(0) 推荐(0) 编辑

2015年3月27日 #

快排

摘要: package com.algorithm;public class Sort {public static void main(String []args){int []a={4,4,5,7,1,8,3,9,11,6};qsort(a,0,a.length-1);for(int i=0;im)j-... 阅读全文

posted @ 2015-03-27 21:37 believer 阅读(153) 评论(0) 推荐(0) 编辑

Single Number II

摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文

posted @ 2015-03-27 19:18 believer 阅读(141) 评论(0) 推荐(0) 编辑

简单工厂和工厂方法

摘要: 简单工厂:一个工厂类根据传入的参量决定创建出哪一种产品类的实例直接一个工厂类,内部通过swith(operator) { case"+": oper=new AddOperation();//产生对象 ...而工厂方法模式:定义一个用于创建对象的接口,让子类决定实例化哪一个类。工厂方法使一个类的... 阅读全文

posted @ 2015-03-27 16:28 believer 阅读(121) 评论(0) 推荐(0) 编辑

Implement strStr()

摘要: Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The si... 阅读全文

posted @ 2015-03-27 13:50 believer 阅读(138) 评论(0) 推荐(0) 编辑

2015年3月26日 #

Linked List Cycle II

摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?/**... 阅读全文

posted @ 2015-03-26 23:17 believer 阅读(151) 评论(0) 推荐(0) 编辑

Linked List Cycle

摘要: //快慢指针public class Solution {public boolean hasCycle(ListNode head) {if(head==null)return false;ListNode slow=head;ListNode fast=head;do{if(fast==null... 阅读全文

posted @ 2015-03-26 22:34 believer 阅读(96) 评论(0) 推荐(0) 编辑

剑指offer总结

摘要: 1、实现Singleton模式2、二维数组中的查找:每行从左到右递增,每列从上到下递增,输入一个数,判断数组中是否存在该数1 2 8 92 4 9 124 7 10 136 8 11 15如输入7:小于第4列的9,则不可能在第4列;column--小于第3列的8,则不可能在第3列;column--大... 阅读全文

posted @ 2015-03-26 15:06 believer 阅读(215) 评论(0) 推荐(0) 编辑

2015年3月24日 #

适配器模式

摘要: 前序姚明,大家都认识吧。在他刚去NBA的时候,什么都听不懂,必须在旁边配个翻译,否则就无法听懂教练在说什么。这也正符合了设计模式中的一种模式:适配器模式。适配器模式将一个类的接口转换成客户希望的另外一个接口。适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。实现方式(UML类图)实... 阅读全文

posted @ 2015-03-24 21:18 believer 阅读(175) 评论(0) 推荐(0) 编辑

Struts2的ActionContext

摘要: web资源:HttpServletRequest,HttpSession,ServletContext等原生Servlet APIAction中如何访问web资源:1、和Servlet API解耦的方式:访问有限的Servlet API对象,访问有限的方法(读取请求参数,读写域对象属性等) a.使用... 阅读全文

posted @ 2015-03-24 15:51 believer 阅读(122) 评论(0) 推荐(0) 编辑