自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 收藏
  • 关注

原创 Heap 堆

Heap 堆, 数组实现

2015-07-22 11:51:27 763

原创 Eclipse

Import: ctrl+shift+o在类中查看方法列表:ctrl+o查看快捷键:ctril+shift+lAssert: assert expression : error message如果expression为false,则报异常。assert默认是disable的,JV运行时要参数-ea

2015-07-21 06:19:14 524

原创 Sort and Shuffle 排序和打乱

排序算法总结

2015-07-20 15:22:47 2729

原创 Java Collection Java集合总结

Java 集合总结,Queue,Stack,List。

2015-07-19 15:09:02 689

原创 操作系统概述(草稿)

SPOOLing 技术: 输入由常驻内存进程统一管理,用户将输入放进输入井里,主机从输入井读取输入,将计算结果放入输出井,输出设备从输出井读取结果。

2015-07-19 12:39:00 391

原创 Stack and Queue 栈和队列

栈的链表实现和数组实现。队列的链表实现和数组实现。应用:计算表达式,十进制转二进制。

2015-07-19 05:13:09 1965

原创 3 sum

3 Sum数组中3个数的和为指定值。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.Example

2015-07-18 15:09:05 688

原创 Algorithm Analysis 算法分析

Verify the predictions by making further observations.Validate by repeating until the hypothesis and observations agree.

2015-07-18 12:09:40 673

原创 Count and Say

Count and Say按规律生成stringThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11. 1个111 is read off

2015-07-18 11:50:11 853

原创 Length of Last Word

Length of Last WordString里最后一个单词的长度Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word d

2015-07-18 11:06:46 676

原创 Longest Words

Longest Words找出数组内最长的stringGiven a dictionary, find all of the longest words in the dictionary.ExampleGiven{ "dog", "google", "facebook", "internationalization", "blabla"}

2015-07-18 10:49:12 750

原创 Reverse Words in a String

Reverse Words in a String翻转string里的单词顺序。Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Solution: public

2015-07-18 10:10:14 714

原创 Median of two Sorted Arrays

Median of two Sorted Arrays在两个数组中找到中位数。There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays.ExampleGiven A=[1,2,3,4,5,6] and

2015-07-18 07:47:31 594

原创 Union Find 并查集

并查集 Union Find.QuickFindQuickUnion

2015-07-18 03:20:53 713 1

原创 Chapter 1 Arrays and Strings

1. 在string中是否含有重复字母public static boolean hasUniqueChar(String string) { // Total 256 characters in ASCII if (string.length() > 256) { return false; } boolean[] count = new boolean[256]; for

2015-07-17 13:58:36 544

原创 Anagrams

Anagrams找出字符串数组里的变位词Given an array of strings, return all groups of strings that are anagrams.ExampleGiven ["lint", "intl", "inlt", "code"], return["lint", "inlt", "intl"].Given ["

2015-07-17 12:02:18 310

原创 String 字符串题目

题目汇总:1. strStr A字符串中是否含有B字符串。遍历即可。2. Two Strings Are Anagrams A字符串中的字符是否和B字符串的字符一致(变位词)。数组自动初始化,先加后减。3. Anagrams 找出字符串数组里的变位词。由数组生成字符串key,存入hashmap。3. Compare Strings A字符串中的字符是否包含了B字符串的字符。数组自动

2015-07-17 11:10:02 644

原创 Two Strings Are Anagrams

Two Strings Are Anagrams判断两个string里的字符和计数是否一致。Write a method anagram(s,t) to decide if two strings are anagrams or not.ExampleGiven s="abcd", t="dcab", return true.Challeng

2015-07-17 11:02:36 636

原创 First Bad Version

First Bad Version Boolean数组中找到第一个true.The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and the follow

2015-07-17 06:28:56 583

原创 Binary Search 二分查找

Binary Search 二分查找。在有序数组中(允许重复数字),查找第一个或最后一个目标数字。时间复杂度为O(logN)。循环方法和递归方法。

2015-07-16 11:08:00 878

原创 Model-View-Controller MVC模式

A compound pattern combines two or more patterns into a solution that solves a recurring or general problem.View根据用户的操作调用对应的Controller的方法。Controller从Model获得当前状态的信息,并修改Model的状态。Model状态修改后通知View,V

2015-07-08 11:02:54 706

原创 Proxy Pattern 代理模式

RMI:1. Create a remote interface, which provides a set of methods that can be called remotely.2. Make sure all arguments and return type in the interface are serializable.3. You can declare tran

2015-07-07 13:31:59 522

原创 State Pattern 状态模式

State Pattern: allows an object to alter its behavior when its internal state changes. The object will appear to changes its class.Encapsulate state into separate classes. With the State Pattern, we

2015-07-07 12:42:11 490

原创 Composite Pattern 组合模式

Composite Pattern: allows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.This

2015-07-07 11:17:43 461

原创 Iterator Pattern 迭代器模式

Iterator Pattern: provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.It also places the task of traversal on the iterator object

2015-07-07 10:05:36 558

原创 Template Method Pattern 模板方法模式

Template Method Pattern: defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing t

2015-07-06 13:13:47 456

原创 Facade Pattern 门面模式

Facade Pattern provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher level interface that makes the subsystem easier to use.门面模式中一个子系统的外部与其内部的通信可以通过一个统一的门面(Faca

2015-07-06 11:48:04 481

原创 Adapter Pattern 适配器模式

Adapter Pattern: converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.Use of obj

2015-07-06 11:34:45 536

原创 Command Pattern 命令模式

Command Pattern: encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.命令模式把一个请求或者操作封装

2015-07-06 05:52:55 500

原创 Singleton Pattern 单例模式

Singleton Pattern: ensures a class has only one instance, and provides a global point of access to it.Note: carefully deal with multithreading.Synchronizing a method can decrease performance by a

2015-07-05 04:39:18 449

原创 Factory Pattern 工厂模式

If your code is written to an interface, then it will work with any new classes implementing that interface through polymorphism. However, when you have code that makes use of lots of concrete classes

2015-07-04 10:50:05 459

原创 Decorator Pattern 装饰者模式

When I inherit behavior by subclassing, that behavior is set statically at compile time. In addition, all subclasses must inherit the same behavior. If however, I can extend an object's behavior throu

2015-07-04 04:12:28 533

原创 Observer Pattern 观察者模式

Publisher, SubjectSubscriber, ObserverObserver Pattern: defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated a

2015-07-04 03:22:37 610

原创 Strategy Pattern 策略模式

Design Principle:Identify the aspects of your application that vary and separate them from what stays the same. 将变化的分离出来,封装变化。Take what varies and "encapsulate" it so it won't affect the rest of t

2015-07-03 13:31:35 549

原创 Appendix

Immutability:String are immutable.Wrappers are immutable.Integer iWrap = new Integer(42);There is no setter method for a wrapper object.You can't change the value of String/Wrapper unless you

2015-07-03 08:49:51 767

原创 Section 18 RMI

Remote Method Interface:Client calls remote method on the stub. So the Client is like making a local call.The stub contacts the server, transfers information about the call and wait for a return f

2015-07-03 08:27:41 477

原创 Section 17 jars

javac -d path *.javamanifest.txt:Main-Class: MyApp(empty line)jar -cvmf mainifest.txt app1.jar *.classjava -jar app1.jarPackages prevent class name conficts.Show the

2015-07-03 06:36:32 413

原创 Section 16 Collections and Generics

Collections:A collection (container) is an object that groups multiple elements into a single unit.TreeSet: Keeps the elements sorted and prevents duplicates.Use red-black tree.HashSet: Prevents

2015-07-03 02:53:26 588

原创 Section 15 network and threads

A port represents a logical connection to a particular piece of software. A number representing an application.TCP port from 0 to 1023 are reserved for well known services.Client:Read data f

2015-07-02 12:14:35 469

原创 Section 14 Serialization

Save object to file: FileOutputStream fileStream = new FileOutputStream("output.out"); ObjectOutputStream os = new ObjectOutputStream(fileStream); os.writeObject(serilaziableObject); os.close()

2015-07-02 11:39:58 441

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除