JasonChang

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

2013年11月25日

摘要: 1 public class Solution { 2 public int singleNumber(int[] A) { 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 = A.length; 6 if(A == null) 7 return 0; 8 ... 阅读全文
posted @ 2013-11-25 09:01 JasonChang 阅读(165) 评论(0) 推荐(0) 编辑

2013年11月24日

摘要: 1 public class Solution { 2 public int maxProfit(int[] prices) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(prices == null||prices.length == 0) 6 return 0; 7 in... 阅读全文
posted @ 2013-11-24 17:14 JasonChang 阅读(224) 评论(0) 推荐(0) 编辑

摘要: 1 /** 2 * Definition for singly-linked list. 3 * class ListNode { 4 * int val; 5 * ListNode next; 6 * ListNode(int x) { 7 * val = x; 8 * next = null; 9 * }10 * }11 */12 public class Solution {13 public boolean hasCycle(ListNode head) {14 // IMPO... 阅读全文
posted @ 2013-11-24 09:19 JasonChang 阅读(192) 评论(0) 推荐(0) 编辑

摘要: bit manipulation 1 public class Solution { 2 public int singleNumber(int[] A) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(A == null || A.length == 0) 6 return 0; 7 ... 阅读全文
posted @ 2013-11-24 08:57 JasonChang 阅读(199) 评论(0) 推荐(0) 编辑

摘要: be careful when x1 = x2 1 /** 2 * Definition for a point. 3 * class Point { 4 * int x; 5 * int y; 6 * Point() { x = 0; y = 0; } 7 * Point(int a, int b) { x = a; y = b; } 8 * } 9 */10 public class Solution {11 public int maxPoints(Point[] points) {12 // IMPORTANT: ... 阅读全文
posted @ 2013-11-24 08:43 JasonChang 阅读(360) 评论(0) 推荐(0) 编辑

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 2 3 4 5 6 7 8 ··· 18 下一页