JasonChang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年11月22日

摘要: Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. example duck application same super class, same function name, different function implementationstructure: 阅读全文
posted @ 2013-11-22 16:31 JasonChang 阅读(206) 评论(0) 推荐(0) 编辑

摘要: 1 public class LRUCache { 2 3 private int capacity; 4 private Map nodes; 5 private int currentSize; 6 private Entry first; 7 private Entry last; 8 9 public LRUCache(int capacity) {10 this.capacity = capacity;11 currentSize = 0;12 nodes = new... 阅读全文
posted @ 2013-11-22 02:40 JasonChang 阅读(227) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList wordBreak(String s, Set dict) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList result = new ArrayList(); 6 if (s == null || ... 阅读全文
posted @ 2013-11-22 02:37 JasonChang 阅读(182) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList fullJustify(String[] words, int L) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 int wordsCount = words.length; 6 ArrayList result ... 阅读全文
posted @ 2013-11-22 02:33 JasonChang 阅读(203) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public double findMedianSortedArrays(int A[], int B[]) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 int aLen = A.length; 6 int bLen = B.length; 7 ... 阅读全文
posted @ 2013-11-22 02:28 JasonChang 阅读(185) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList findSubstring(String S, String[] L) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList results = new ArrayList(); 6 int len = ... 阅读全文
posted @ 2013-11-22 02:11 JasonChang 阅读(217) 评论(0) 推荐(0) 编辑