- 博客(43)
- 收藏
- 关注
原创 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 537
原创 操作系统概述(草稿)
SPOOLing 技术: 输入由常驻内存进程统一管理,用户将输入放进输入井里,主机从输入井读取输入,将计算结果放入输出井,输出设备从输出井读取结果。
2015-07-19 12:39:00 409
原创 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 711
原创 Algorithm Analysis 算法分析
Verify the predictions by making further observations.Validate by repeating until the hypothesis and observations agree.
2015-07-18 12:09:40 693
原创 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 870
原创 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 699
原创 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 768
原创 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 734
原创 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 620
原创 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 565
原创 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 322
原创 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 662
原创 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 650
原创 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 600
原创 Binary Search 二分查找
Binary Search 二分查找。在有序数组中(允许重复数字),查找第一个或最后一个目标数字。时间复杂度为O(logN)。循环方法和递归方法。
2015-07-16 11:08:00 894
原创 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 721
原创 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 582
原创 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 508
原创 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 472
原创 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 578
原创 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 470
原创 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 491
原创 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 545
原创 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 526
原创 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 460
原创 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 473
原创 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 545
原创 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 625
原创 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 572
原创 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 785
原创 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 495
原创 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 424
原创 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 604
原创 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 482
原创 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 451
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人