JasonChang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 2 3 4 5 6 7 ··· 18 下一页

2013年12月2日

摘要: The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.implementation 阅读全文
posted @ 2013-12-02 15:32 JasonChang 阅读(116) 评论(0) 推荐(0) 编辑

摘要: The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.implementation 阅读全文
posted @ 2013-12-02 13:09 JasonChang 阅读(217) 评论(0) 推荐(0) 编辑

摘要: The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extendingfunctionality.implementation 阅读全文
posted @ 2013-12-02 12:21 JasonChang 阅读(132) 评论(0) 推荐(0) 编辑

摘要: The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically. Observer Pattern = Publisher + Subcribersimplemenation: 阅读全文
posted @ 2013-12-02 08:37 JasonChang 阅读(143) 评论(0) 推荐(0) 编辑

2013年12月1日

摘要: 1 /** 2 * Definition for singly-linked list with a random pointer. 3 * class RandomListNode { 4 * int label; 5 * RandomListNode next, random; 6 * RandomListNode(int x) { this.label = x; } 7 * }; 8 */ 9 public class Solution {10 public RandomListNode copyRandomList(RandomListN... 阅读全文
posted @ 2013-12-01 13:18 JasonChang 阅读(345) 评论(0) 推荐(0) 编辑

2013年11月30日

摘要: 1 public class Solution { 2 public int[] twoSum(int[] numbers, int target) { 3 HashMap visited = new HashMap(); 4 int[] result = new int[2]; 5 for(int i = 0; i < numbers.length; i++){ 6 int tmp = target - numbers[i]; 7 if(visited.containsKey(tmp))... 阅读全文
posted @ 2013-11-30 14:29 JasonChang 阅读(128) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ListNode addTwoNumbers(ListNode l1, ListNode l2) { 3 if(l1 == null) 4 return l2; 5 if(l2 == null) 6 return l1; 7 ListNode fakehead = new ListNode(0); 8 ListNode pre = fakehead; 9 int carry = 0;10 ... 阅读全文
posted @ 2013-11-30 13:23 JasonChang 阅读(150) 评论(0) 推荐(0) 编辑

2013年11月28日

摘要: 1 public class Solution { 2 public int longestConsecutive(int[] num) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 int len = num.length; 6 if(len table = new HashMap(); 9 ... 阅读全文
posted @ 2013-11-28 08:41 JasonChang 阅读(170) 评论(0) 推荐(0) 编辑

摘要: String equals() == 1 public class Solution { 2 public int evalRPN(String[] tokens) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 Stack stack = new Stack(); 6 if(tokens == null |... 阅读全文
posted @ 2013-11-28 02:44 JasonChang 阅读(171) 评论(0) 推荐(0) 编辑

2013年11月26日

摘要: 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNode(int x) { val = x; } 8 * } 9 */10 public class Solution {11 public int minDepth(TreeNode root) {12 // IMPORTANT: Please reset any memb... 阅读全文
posted @ 2013-11-26 06:45 JasonChang 阅读(172) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 18 下一页